mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 01:25:37 +01:00
Merge pull request #3306 from harryo/bugfix/other-domain-groups
Fix counting _other domain groups
This commit is contained in:
commit
bc2518a369
1 changed files with 13 additions and 8 deletions
|
|
@ -60,19 +60,24 @@ export function ReferrersTable({ allowFilter, ...props }: ReferrersTableProps) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDomain = (x: string) => {
|
||||||
|
for (const { domain, match } of GROUPED_DOMAINS) {
|
||||||
|
if (Array.isArray(match) ? match.some(str => x.includes(str)) : x.includes(match)) {
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '_other';
|
||||||
|
};
|
||||||
|
|
||||||
const groupedFilter = (data: any[]) => {
|
const groupedFilter = (data: any[]) => {
|
||||||
const groups = { _other: 0 };
|
const groups = { _other: 0 };
|
||||||
|
|
||||||
for (const { x, y } of data) {
|
for (const { x, y } of data) {
|
||||||
for (const { domain, match } of GROUPED_DOMAINS) {
|
const domain = getDomain(x);
|
||||||
if (Array.isArray(match) ? match.some(str => x.includes(str)) : x.includes(match)) {
|
if (!groups[domain]) {
|
||||||
if (!groups[domain]) {
|
groups[domain] = 0;
|
||||||
groups[domain] = 0;
|
|
||||||
}
|
|
||||||
groups[domain] += +y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
groups._other += +y;
|
groups[domain] += +y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.keys(groups)
|
return Object.keys(groups)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue