Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Update filters and sorting.

Mike Caof34c8f8ec868
diff --git a/components/metrics/MetricsTable.js b/components/metrics/MetricsTable.js
index 16f618365..25bb4a086 100644
--- a/components/metrics/MetricsTable.js
+++ b/components/metrics/MetricsTable.js
@@ -1,5 +1,6 @@
import React, { useMemo } from 'react';
import { FormattedMessage } from 'react-intl';
+import firstBy from 'thenby';
import classNames from 'classnames';
import Link from 'components/common/Link';
import Loading from 'components/common/Loading';
@@ -55,9 +56,9 @@ export default function MetricsTable({
if (data) {
const items = percentFilter(dataFilter ? dataFilter(data, filterOptions) : data);
if (limit) {
- return items.filter((e, i) => i < limit);
+ return items.filter((e, i) => i < limit).sort(firstBy('y', -1).thenBy('x'));
}
- return items;
+ return items.sort(firstBy('y', -1).thenBy('x'));
}
return [];
}, [data, error, dataFilter, filterOptions]);
diff --git a/lib/filters.js b/lib/filters.js
index 7fd5d833a..d48536185 100644
--- a/lib/filters.js
+++ b/lib/filters.js
@@ -1,4 +1,3 @@
-import firstBy from 'thenby';
import { BROWSERS } from './constants';
import { removeTrailingSlash, removeWWW, getDomainName } from './url';
@@ -43,9 +42,7 @@ export const urlFilter = (data, { raw }) => {
return obj;
}, {});
- return Object.keys(map)
- .map(key => ({ x: key, y: map[key] }))
- .sort(firstBy('y', -1).thenBy('x'));
+ return Object.keys(map).map(key => ({ x: key, y: map[key] }));
};
export const refFilter = (data, { domain, domainOnly, raw }) => {
@@ -70,7 +67,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
}
if (domainOnly && hostname) {
- return hostname;
+ return removeWWW(hostname);
}
if (!origin || origin === 'null') {
@@ -113,9 +110,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
return obj;
}, {});
- return Object.keys(map)
- .map(key => ({ x: key, y: map[key], w: links[key] }))
- .sort(firstBy('y', -1).thenBy('x'));
+ return Object.keys(map).map(key => ({ x: key, y: map[key], w: links[key] }));
};
export const browserFilter = data =>