mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 16:17:13 +01:00
add event name to properties table
This commit is contained in:
parent
04de691893
commit
aaf9adacc6
5 changed files with 44 additions and 16 deletions
|
|
@ -4,7 +4,10 @@ import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
|||
import { QueryFilters, WebsiteEventData } from 'lib/types';
|
||||
|
||||
export async function getEventDataValues(
|
||||
...args: [websiteId: string, filters: QueryFilters & { propertyName?: string }]
|
||||
...args: [
|
||||
websiteId: string,
|
||||
filters: QueryFilters & { eventName?: string; propertyName?: string },
|
||||
]
|
||||
): Promise<WebsiteEventData[]> {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -14,7 +17,7 @@ export async function getEventDataValues(
|
|||
|
||||
async function relationalQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters & { propertyName?: string },
|
||||
filters: QueryFilters & { eventName?: string; propertyName?: string },
|
||||
) {
|
||||
const { rawQuery, parseFilters } = prisma;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, filters);
|
||||
|
|
@ -28,6 +31,7 @@ async function relationalQuery(
|
|||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and data_key = {{propertyName}}
|
||||
and event_key = {{eventName}}
|
||||
${filterQuery}
|
||||
group by string_value
|
||||
order by 2 desc
|
||||
|
|
@ -39,7 +43,7 @@ async function relationalQuery(
|
|||
|
||||
async function clickhouseQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters & { propertyName?: string },
|
||||
filters: QueryFilters & { eventName?: string; propertyName?: string },
|
||||
): Promise<{ propertyName: string; dataType: number; propertyValue: string; total: number }[]> {
|
||||
const { rawQuery, parseFilters } = clickhouse;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, filters);
|
||||
|
|
@ -55,8 +59,9 @@ async function clickhouseQuery(
|
|||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and data_key = {propertyName:String}
|
||||
and event_name = {eventName:String}
|
||||
${filterQuery}
|
||||
group by value
|
||||
group by event_name, value
|
||||
order by 2 desc
|
||||
limit 500;
|
||||
`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue