mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Refactored queries.
This commit is contained in:
parent
e4bd314bd6
commit
4bd3ef8e12
19 changed files with 330 additions and 408 deletions
|
|
@ -11,31 +11,32 @@ export async function getActiveVisitors(...args: [websiteId: string]) {
|
|||
}
|
||||
|
||||
async function relationalQuery(websiteId: string) {
|
||||
const { toUuid, rawQuery } = prisma;
|
||||
|
||||
const date = subMinutes(new Date(), 5);
|
||||
const params: any = [websiteId, date];
|
||||
const { rawQuery } = prisma;
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
`
|
||||
select count(distinct session_id) x
|
||||
from website_event
|
||||
join website
|
||||
join website
|
||||
on website_event.website_id = website.website_id
|
||||
where website.website_id = $1${toUuid()}
|
||||
and website_event.created_at >= $2`,
|
||||
params,
|
||||
where website.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at >= {{startAt}}
|
||||
`,
|
||||
{ websiteId, startAt: subMinutes(new Date(), 5) },
|
||||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string) {
|
||||
const { rawQuery } = clickhouse;
|
||||
const params = { websiteId, startAt: subMinutes(new Date(), 5) };
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
`
|
||||
select
|
||||
count(distinct session_id) x
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startAt:DateTime('UTC')}`,
|
||||
params,
|
||||
and created_at >= {startAt:DateTime}
|
||||
`,
|
||||
{ websiteId, startAt: subMinutes(new Date(), 5) },
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue