Fixed visits getting accumulated every time the visits page is opened

This commit is contained in:
Alejandro Celaya 2020-11-14 13:01:35 +01:00
parent dafebc3df9
commit 3e21cccb14

View file

@ -1,4 +1,4 @@
import { isNil, map, reduce } from 'ramda';
import { isNil, map } from 'ramda';
import { extractDomain, parseUserAgent } from '../../utils/helpers/visits';
import { hasValue } from '../../utils/utils';
import { CityStats, NormalizedVisit, Stats, Visit, VisitsStats } from '../types';
@ -53,7 +53,7 @@ const updateCitiesForMapForVisit = (citiesForMapStats: Record<string, CityStats>
citiesForMapStats[city] = currentCity;
};
export const processStatsFromVisits = reduce(
export const processStatsFromVisits = (visits: NormalizedVisit[]) => visits.reduce(
(stats: VisitsStats, visit: NormalizedVisit) => {
// We mutate the original object because it has a big performance impact when large data sets are processed
updateOsStatsForVisit(stats.os, visit);