Filter out null entries.

This commit is contained in:
Mike Cao 2020-08-23 18:01:27 -07:00
parent 8739e3624f
commit d91fd2492c
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import MetricsTable from './MetricsTable'; import MetricsTable from './MetricsTable';
import { osFilter } from 'lib/filters';
export default function OSTable({ websiteId, startDate, endDate, limit, onExpand }) { export default function OSTable({ websiteId, startDate, endDate, limit, onExpand }) {
return ( return (
@ -11,6 +12,7 @@ export default function OSTable({ websiteId, startDate, endDate, limit, onExpand
startDate={startDate} startDate={startDate}
endDate={endDate} endDate={endDate}
limit={limit} limit={limit}
dataFilter={osFilter}
onExpand={onExpand} onExpand={onExpand}
/> />
); );

View File

@ -2,9 +2,6 @@ import firstBy from 'thenby';
import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants'; import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants';
import { removeTrailingSlash } from './format'; import { removeTrailingSlash } from './format';
export const browserFilter = data =>
data.map(({ x, ...props }) => ({ x: BROWSERS[x] || x, ...props }));
export const urlFilter = (data, { domain, raw }) => { export const urlFilter = (data, { domain, raw }) => {
const isValidUrl = url => { const isValidUrl = url => {
return url !== '' && !url.startsWith('#'); return url !== '' && !url.startsWith('#');
@ -114,11 +111,16 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
.sort(firstBy('y', -1).thenBy('x')); .sort(firstBy('y', -1).thenBy('x'));
}; };
export const browserFilter = data =>
data.map(({ x, y }) => ({ x: BROWSERS[x], y })).filter(({ x }) => x);
export const osFilter = data => data.filter(({ x }) => x);
export const deviceFilter = data => export const deviceFilter = data =>
data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props })); data.map(({ x, y }) => ({ x: DEVICES[x], y })).filter(({ x }) => x);
export const countryFilter = data => export const countryFilter = data =>
data.map(({ x, ...props }) => ({ x: ISO_COUNTRIES[x] || x, ...props })); data.map(({ x, y }) => ({ x: ISO_COUNTRIES[x], y })).filter(({ x }) => x);
export const percentFilter = data => { export const percentFilter = data => {
const total = data.reduce((n, { y }) => n + y, 0); const total = data.reduce((n, { y }) => n + y, 0);