fix cohort queries with new multiselect
Some checks are pending
Node.js CI / build (push) Waiting to run

This commit is contained in:
Francis Cao 2026-02-20 15:03:24 -08:00
parent f2cf071523
commit bbf569e8bc
3 changed files with 10 additions and 4 deletions

View file

@ -178,7 +178,10 @@ function getQueryParams(filters: Record<string, any>) {
return { return {
...filters, ...filters,
...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => { ...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) obj[name] = ([OPERATORS.equals, OPERATORS.notEquals] as string[]).includes(operator)
? Array.isArray(value) ? Array.isArray(value)

View file

@ -182,7 +182,10 @@ function getQueryParams(filters: Record<string, any>) {
return { return {
...filters, ...filters,
...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => { ...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)) { if (([OPERATORS.contains, OPERATORS.doesNotContain] as Operator[]).includes(operator)) {
obj[name] = `%${value}%`; obj[name] = `%${value}%`;

View file

@ -1,7 +1,7 @@
import { startOfMonth, subMonths } from 'date-fns'; import { startOfMonth, subMonths } from 'date-fns';
import { z } from 'zod'; import { z } from 'zod';
import { checkAuth } from '@/lib/auth'; 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 { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
import { fetchAccount, fetchWebsite } from '@/lib/load'; import { fetchAccount, fetchWebsite } from '@/lib/load';
import { filtersArrayToObject } from '@/lib/params'; import { filtersArrayToObject } from '@/lib/params';
@ -130,7 +130,7 @@ export async function getQueryFilters(
cohortFilters.push({ cohortFilters.push({
name: `cohort_${cohortParams.action.type}`, name: `cohort_${cohortParams.action.type}`,
operator: 'eq', operator: OPERATORS.equals,
value: cohortParams.action.value, value: cohortParams.action.value,
}); });