Merge pull request #777 from acelaya-forks/feature/fix-visits-filters

Fixed bots filter getting reset when changing date
This commit is contained in:
Alejandro Celaya 2022-12-25 09:49:57 +01:00 committed by GitHub
commit 51283cc130
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -87,13 +87,11 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
() => processStatsFromVisits(normalizedVisits),
[normalizedVisits],
);
const resolvedFilter = useMemo(() => ({
...visitsFilter,
excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots,
}), [visitsFilter]);
const mapLocations = values(citiesForMap);
const resolvedFilter = useMemo(() => (
!isFirstLoad.current ? visitsFilter : {
...visitsFilter,
excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots,
}
), [visitsFilter]);
const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => {
selectedBar = undefined;

View file

@ -6,7 +6,7 @@ import { DateRange, datesToDateRange } from '../../utils/helpers/dateIntervals';
import { OrphanVisitType, VisitsFilter } from '../types';
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
import { formatIsoDate } from '../../utils/helpers/date';
import { BooleanString } from '../../utils/utils';
import { BooleanString, parseBooleanToString } from '../../utils/utils';
interface VisitsQuery {
startDate?: string;
@ -47,11 +47,12 @@ export const useVisitsQuery = (): [VisitsFiltering, UpdateFiltering] => {
);
const updateFiltering = (extra: DeepPartial<VisitsFiltering>) => {
const { dateRange, visitsFilter } = mergeDeepRight(filtering, extra);
const { excludeBots, orphanVisitsType } = visitsFilter;
const query: VisitsQuery = {
startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '',
endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '',
excludeBots: visitsFilter.excludeBots ? 'true' : 'false',
orphanVisitsType: visitsFilter.orphanVisitsType,
excludeBots: excludeBots === undefined ? undefined : parseBooleanToString(excludeBots),
orphanVisitsType,
domain: theDomain,
};
const stringifiedQuery = stringifyQuery(query);