mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Updated cohort processing.
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run
This commit is contained in:
parent
c3b62e3a74
commit
f9442001e4
8 changed files with 46 additions and 56 deletions
|
|
@ -90,7 +90,9 @@ export function CohortEditForm({
|
|||
<Form
|
||||
error={error}
|
||||
onSubmit={handleSubmit}
|
||||
defaultValues={data || { parameters: { filters, dateRange: '30day' } }}
|
||||
defaultValues={
|
||||
data || { parameters: { filters, dateRange: '30day', action: { type: 'path' } } }
|
||||
}
|
||||
>
|
||||
<FormField
|
||||
name="name"
|
||||
|
|
@ -104,14 +106,19 @@ export function CohortEditForm({
|
|||
<Label>{formatMessage(labels.action)}</Label>
|
||||
<Grid columns="260px 1fr" gap>
|
||||
<Column>
|
||||
<Select value={action} onChange={setAction}>
|
||||
<ListItem id="path">{formatMessage(labels.viewedPage)}</ListItem>
|
||||
<ListItem id="event">{formatMessage(labels.triggeredEvent)}</ListItem>
|
||||
</Select>
|
||||
<FormField
|
||||
name="parameters.action.type"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<Select onSelectionChange={(value: any) => setAction(value)}>
|
||||
<ListItem id="path">{formatMessage(labels.viewedPage)}</ListItem>
|
||||
<ListItem id="event">{formatMessage(labels.triggeredEvent)}</ListItem>
|
||||
</Select>
|
||||
</FormField>
|
||||
</Column>
|
||||
<Column>
|
||||
<FormField
|
||||
name="parameters.action"
|
||||
name="parameters.action.value"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
{({ field }) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { canViewWebsite } from '@/validations';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, FILTER_GROUPS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, SEGMENT_TYPES, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||
import { getWebsiteSegments, getValues } from '@/queries';
|
||||
|
|
@ -30,14 +30,16 @@ export async function GET(
|
|||
|
||||
const { type } = query;
|
||||
|
||||
if (!SESSION_COLUMNS.includes(type) && !EVENT_COLUMNS.includes(type) && !FILTER_GROUPS[type]) {
|
||||
if (!SESSION_COLUMNS.includes(type) && !EVENT_COLUMNS.includes(type) && !SEGMENT_TYPES[type]) {
|
||||
return badRequest();
|
||||
}
|
||||
|
||||
let values;
|
||||
let values: any[];
|
||||
|
||||
if (FILTER_GROUPS[type]) {
|
||||
values = (await getWebsiteSegments(websiteId, type)).map(segment => ({ value: segment.name }));
|
||||
if (SEGMENT_TYPES[type]) {
|
||||
values = (await getWebsiteSegments(websiteId, type))?.data?.map(segment => ({
|
||||
value: segment.name,
|
||||
}));
|
||||
} else {
|
||||
const filters = await getQueryFilters(query, websiteId);
|
||||
values = await getValues(websiteId, FILTER_COLUMNS[type], filters);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue