mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Add user usage.
This commit is contained in:
parent
c41fb5ee1b
commit
9e2a478001
5 changed files with 142 additions and 2 deletions
32
queries/analytics/eventData/getEventDataUsage.ts
Normal file
32
queries/analytics/eventData/getEventDataUsage.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import clickhouse from 'lib/clickhouse';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
||||
|
||||
export function getEventDataUsage(...args: [websiteIds: string[], startDate: Date, endDate: Date]) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
function relationalQuery(websiteIds: string[], startDate: Date, endDate: Date) {
|
||||
throw new Error('Not Implemented');
|
||||
}
|
||||
|
||||
function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {
|
||||
const { rawQuery } = clickhouse;
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
website_id as websiteId,
|
||||
count(*) as count
|
||||
from event_data
|
||||
where created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and website_id in {websiteIds:Array(UUID)}
|
||||
group by website_id`,
|
||||
{
|
||||
websiteIds,
|
||||
startDate,
|
||||
endDate,
|
||||
},
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue