mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +01:00
segments implementation and migration update. update getRequestFilters to include filter groups.
This commit is contained in:
parent
1ccc8a1a86
commit
f61421b742
16 changed files with 188 additions and 23 deletions
|
|
@ -32,7 +32,7 @@ export async function GET(
|
|||
}
|
||||
|
||||
const filters = {
|
||||
...getRequestFilters(query),
|
||||
...(await getRequestFilters(query)),
|
||||
startDate,
|
||||
endDate,
|
||||
timezone,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export async function GET(
|
|||
const { startDate, endDate } = await getRequestDateRange(query);
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const filters = {
|
||||
...getRequestFilters(query),
|
||||
...(await getRequestFilters(query)),
|
||||
startDate,
|
||||
endDate,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export async function GET(
|
|||
const { startDate, endDate, unit } = await getRequestDateRange(query);
|
||||
|
||||
const filters = {
|
||||
...getRequestFilters(query),
|
||||
...(await getRequestFilters(query)),
|
||||
startDate,
|
||||
endDate,
|
||||
timezone,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export async function GET(
|
|||
|
||||
const { startDate, endDate } = await getRequestDateRange(query);
|
||||
|
||||
const filters = getRequestFilters(query);
|
||||
const filters = await getRequestFilters(query);
|
||||
|
||||
const metrics = await getWebsiteSessionStats(websiteId, {
|
||||
...filters,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export async function GET(
|
|||
endDate,
|
||||
);
|
||||
|
||||
const filters = getRequestFilters(query);
|
||||
const filters = await getRequestFilters(query);
|
||||
|
||||
const metrics = await getWebsiteStats(websiteId, {
|
||||
...filters,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from 'zod';
|
||||
import { canViewWebsite } from '@/lib/auth';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, GROUP_FILTERS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { getValues } from '@/queries';
|
||||
import { parseRequest, getRequestDateRange } from '@/lib/request';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, FILTER_GROUPS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { getRequestDateRange, parseRequest } from '@/lib/request';
|
||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||
import { getWebsiteSegments, getValues } from '@/queries';
|
||||
import { z } from 'zod';
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
|
|
@ -33,12 +33,18 @@ export async function GET(
|
|||
if (
|
||||
!SESSION_COLUMNS.includes(type) &&
|
||||
!EVENT_COLUMNS.includes(type) &&
|
||||
!GROUP_FILTERS.includes(type)
|
||||
!FILTER_GROUPS.includes(type)
|
||||
) {
|
||||
return badRequest('Invalid type.');
|
||||
}
|
||||
|
||||
const values = await getValues(websiteId, FILTER_COLUMNS[type], startDate, endDate, search);
|
||||
let values;
|
||||
|
||||
if (FILTER_GROUPS.includes(type)) {
|
||||
values = (await getWebsiteSegments(websiteId, type)).map(segment => ({ value: segment.name }));
|
||||
} else {
|
||||
values = await getValues(websiteId, FILTER_COLUMNS[type], startDate, endDate, search);
|
||||
}
|
||||
|
||||
return json(values.filter(n => n).sort());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue