Allow multiple filters.

This commit is contained in:
Mike Cao 2023-05-16 19:17:12 -07:00
parent 2ce62c1023
commit b48efef38b
2 changed files with 16 additions and 5 deletions

View File

@ -73,16 +73,27 @@ export function MetricsTable({
const filteredData = useMemo(() => {
if (data) {
const dataWithoutNullValues = data.filter(val => val.x !== null);
let items = percentFilter(
dataFilter ? dataFilter(dataWithoutNullValues, filterOptions) : dataWithoutNullValues,
);
let items;
if (dataFilter) {
if (Array.isArray(dataFilter)) {
items = dataFilter.reduce((arr, filter) => {
return filter(arr);
}, data);
} else {
items = dataFilter(data);
}
}
items = percentFilter(items);
if (limit) {
items = items.filter((e, i) => i < limit);
}
if (filterOptions?.sort === false) {
return items;
}
return items.sort(firstBy('y', -1).thenBy('x'));
}
return [];

View File

@ -9,7 +9,7 @@ import styles from './QueryParametersTable.module.css';
const filters = {
[FILTER_RAW]: emptyFilter,
[FILTER_COMBINED]: paramFilter,
[FILTER_COMBINED]: [emptyFilter, paramFilter],
};
export function QueryParametersTable({ websiteId, showFilters, ...props }) {