mirror of
https://github.com/umami-software/umami.git
synced 2026-02-24 22:45:36 +01:00
fix cohort queries with new multiselect
Some checks are pending
Node.js CI / build (push) Waiting to run
Some checks are pending
Node.js CI / build (push) Waiting to run
This commit is contained in:
parent
f2cf071523
commit
bbf569e8bc
3 changed files with 10 additions and 4 deletions
|
|
@ -178,7 +178,10 @@ function getQueryParams(filters: Record<string, any>) {
|
|||
return {
|
||||
...filters,
|
||||
...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => {
|
||||
if (!column || !name || value === undefined) return obj;
|
||||
const resolvedColumn =
|
||||
column || (name?.startsWith('cohort_') && FILTER_COLUMNS[name.slice('cohort_'.length)]);
|
||||
|
||||
if (!resolvedColumn || !name || value === undefined) return obj;
|
||||
|
||||
obj[name] = ([OPERATORS.equals, OPERATORS.notEquals] as string[]).includes(operator)
|
||||
? Array.isArray(value)
|
||||
|
|
|
|||
|
|
@ -182,7 +182,10 @@ function getQueryParams(filters: Record<string, any>) {
|
|||
return {
|
||||
...filters,
|
||||
...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => {
|
||||
if (!column) return obj;
|
||||
const resolvedColumn =
|
||||
column || (name?.startsWith('cohort_') && FILTER_COLUMNS[name.slice('cohort_'.length)]);
|
||||
|
||||
if (!resolvedColumn) return obj;
|
||||
|
||||
if (([OPERATORS.contains, OPERATORS.doesNotContain] as Operator[]).includes(operator)) {
|
||||
obj[name] = `%${value}%`;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { startOfMonth, subMonths } from 'date-fns';
|
||||
import { z } from 'zod';
|
||||
import { checkAuth } from '@/lib/auth';
|
||||
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS, OPERATORS } from '@/lib/constants';
|
||||
import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
|
||||
import { fetchAccount, fetchWebsite } from '@/lib/load';
|
||||
import { filtersArrayToObject } from '@/lib/params';
|
||||
|
|
@ -130,7 +130,7 @@ export async function getQueryFilters(
|
|||
|
||||
cohortFilters.push({
|
||||
name: `cohort_${cohortParams.action.type}`,
|
||||
operator: 'eq',
|
||||
operator: OPERATORS.equals,
|
||||
value: cohortParams.action.value,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue