mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Updated pixel/link endpoints. Added name to rawQuery.
This commit is contained in:
parent
b9fbbc6453
commit
8a977b0164
18 changed files with 913 additions and 810 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import clickhouse from '@/lib/clickhouse';
|
||||
import { EVENT_COLUMNS, EVENT_TYPE, FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { EVENT_COLUMNS, FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import prisma from '@/lib/prisma';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getSessionMetrics';
|
||||
|
||||
export interface SessionMetricsParameters {
|
||||
type: string;
|
||||
limit?: number | string;
|
||||
|
|
@ -31,7 +33,6 @@ async function relationalQuery(
|
|||
{
|
||||
...filters,
|
||||
websiteId,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
},
|
||||
{
|
||||
joinSession: SESSION_COLUMNS.includes(type),
|
||||
|
|
@ -54,6 +55,7 @@ async function relationalQuery(
|
|||
${joinSessionQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and event_type != 2
|
||||
${filterQuery}
|
||||
group by 1
|
||||
${includeCountry ? ', 3' : ''}
|
||||
|
|
@ -62,6 +64,7 @@ async function relationalQuery(
|
|||
offset ${offset}
|
||||
`,
|
||||
{ ...queryParams, ...parameters },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +79,6 @@ async function clickhouseQuery(
|
|||
const { filterQuery, cohortQuery, queryParams } = parseFilters({
|
||||
...filters,
|
||||
websiteId,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
});
|
||||
const includeCountry = column === 'city' || column === 'region';
|
||||
|
||||
|
|
@ -96,6 +98,7 @@ async function clickhouseQuery(
|
|||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type != 2
|
||||
${filterQuery}
|
||||
group by x
|
||||
${includeCountry ? ', country' : ''}
|
||||
|
|
@ -113,6 +116,7 @@ async function clickhouseQuery(
|
|||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type != 2
|
||||
${filterQuery}
|
||||
group by x
|
||||
${includeCountry ? ', country' : ''}
|
||||
|
|
@ -122,5 +126,5 @@ async function clickhouseQuery(
|
|||
`;
|
||||
}
|
||||
|
||||
return rawQuery(sql, { ...queryParams, ...parameters });
|
||||
return rawQuery(sql, { ...queryParams, ...parameters }, FUNCTION_NAME);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue