mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Added more function names to queries.
This commit is contained in:
parent
cd6ad0add2
commit
da572864ac
25 changed files with 118 additions and 20 deletions
|
|
@ -3,6 +3,8 @@ import prisma from '@/lib/prisma';
|
|||
import clickhouse from '@/lib/clickhouse';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
|
||||
const FUNCTION_NAME = 'getEventData';
|
||||
|
||||
export async function getEventData(...args: [eventId: string]): Promise<EventData[]> {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -30,6 +32,7 @@ async function relationalQuery(eventId: string) {
|
|||
where event_id = {{eventId::uuid}}
|
||||
`,
|
||||
{ eventId },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -53,5 +56,6 @@ async function clickhouseQuery(eventId: string): Promise<EventData[]> {
|
|||
where event_id = {eventId:UUID}
|
||||
`,
|
||||
{ eventId },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataEvents';
|
||||
|
||||
export interface WebsiteEventData {
|
||||
eventName?: string;
|
||||
propertyName: string;
|
||||
|
|
@ -44,6 +46,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
order by 1 asc, 2 asc, 3 asc, 5 desc
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -59,11 +62,10 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
on website_event.event_id = event_data.website_event_id
|
||||
where event_data.website_id = {{websiteId::uuid}}
|
||||
and event_data.created_at between {{startDate}} and {{endDate}}
|
||||
group by website_event.event_name, event_data.data_key, event_data.data_type
|
||||
order by 1 asc, 2 asc
|
||||
limit 500
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +95,7 @@ async function clickhouseQuery(
|
|||
limit 500
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -111,5 +114,6 @@ async function clickhouseQuery(
|
|||
limit 500
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
|||
import prisma from '@/lib/prisma';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataFields';
|
||||
|
||||
export async function getEventDataFields(...args: [websiteId: string, filters: QueryFilters]) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -42,6 +44,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
limit 100
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -71,5 +74,6 @@ async function clickhouseQuery(
|
|||
limit 100
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataProperties';
|
||||
|
||||
export async function getEventDataProperties(
|
||||
...args: [websiteId: string, filters: QueryFilters & { propertyName?: string }]
|
||||
) {
|
||||
|
|
@ -44,6 +46,7 @@ async function relationalQuery(
|
|||
limit 500
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -75,5 +78,6 @@ async function clickhouseQuery(
|
|||
limit 500
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataStats';
|
||||
|
||||
export async function getEventDataStats(
|
||||
...args: [websiteId: string, filters: QueryFilters]
|
||||
): Promise<{
|
||||
|
|
@ -47,6 +49,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
) as t
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -77,5 +80,6 @@ async function clickhouseQuery(
|
|||
) as t
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery, notImplemented } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataUsage';
|
||||
|
||||
export function getEventDataUsage(...args: [websiteIds: string[], filters: QueryFilters]) {
|
||||
return runQuery({
|
||||
[PRISMA]: notImplemented,
|
||||
|
|
@ -31,5 +33,6 @@ function clickhouseQuery(
|
|||
startDate,
|
||||
endDate,
|
||||
},
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventDataValues';
|
||||
|
||||
interface WebsiteEventData {
|
||||
value: string;
|
||||
total: number;
|
||||
|
|
@ -55,6 +57,7 @@ async function relationalQuery(
|
|||
limit 100
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -84,5 +87,6 @@ async function clickhouseQuery(
|
|||
limit 100
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
|||
import prisma from '@/lib/prisma';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventExpandedMetrics';
|
||||
|
||||
export interface EventExpandedMetricParameters {
|
||||
type: string;
|
||||
limit?: string;
|
||||
|
|
@ -61,6 +63,7 @@ async function relationalQuery(
|
|||
offset ${offset}
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -108,5 +111,6 @@ async function clickhouseQuery(
|
|||
offset ${offset}
|
||||
`,
|
||||
{ ...queryParams, ...parameters },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
|||
import prisma from '@/lib/prisma';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventStats';
|
||||
|
||||
interface WebsiteEventMetric {
|
||||
x: string;
|
||||
t: string;
|
||||
|
|
@ -44,6 +46,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
order by 2
|
||||
`,
|
||||
queryParams,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -94,5 +97,5 @@ async function clickhouseQuery(
|
|||
`;
|
||||
}
|
||||
|
||||
return rawQuery(sql, queryParams);
|
||||
return rawQuery(sql, queryParams, FUNCTION_NAME);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import clickhouse from '@/lib/clickhouse';
|
|||
import { CLICKHOUSE, PRISMA, runQuery, notImplemented } from '@/lib/db';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getEventUsage';
|
||||
|
||||
export function getEventUsage(...args: [websiteIds: string[], filters: QueryFilters]) {
|
||||
return runQuery({
|
||||
[PRISMA]: notImplemented,
|
||||
|
|
@ -31,5 +33,6 @@ function clickhouseQuery(
|
|||
startDate,
|
||||
endDate,
|
||||
},
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
|||
import prisma from '@/lib/prisma';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
const FUNCTION_NAME = 'getWebsiteEvents';
|
||||
|
||||
export function getWebsiteEvents(...args: [websiteId: string, filters: QueryFilters]) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -56,6 +58,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
`,
|
||||
queryParams,
|
||||
filters,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -104,5 +107,6 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||
`,
|
||||
queryParams,
|
||||
filters,
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue