mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 04:25:39 +01:00
Feat/um 154 add event data rewrite queries (#1739)
* Cherry pick prisma query protection. * Re-write CH queries to use query params. * Fix query. * Fix modal. Re-add form css.
This commit is contained in:
parent
4c202741c2
commit
0409a7d261
19 changed files with 257 additions and 185 deletions
|
|
@ -11,29 +11,31 @@ export async function getActiveVisitors(...args: [websiteId: string]) {
|
|||
}
|
||||
|
||||
async function relationalQuery(websiteId: string) {
|
||||
const date = subMinutes(new Date(), 5);
|
||||
const params = [date];
|
||||
const { toUuid, rawQuery } = prisma;
|
||||
|
||||
return prisma.rawQuery(
|
||||
const date = subMinutes(new Date(), 5);
|
||||
const params: any = [websiteId, date];
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
from pageview
|
||||
from website_event
|
||||
join website
|
||||
on pageview.website_id = website.website_id
|
||||
where website.website_id = '${websiteId}'
|
||||
and pageview.created_at >= $1`,
|
||||
on website_event.website_id = website.website_id
|
||||
where website.website_id = $1${toUuid()}
|
||||
and website_event.created_at >= $2`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(websiteId: string) {
|
||||
const { rawQuery, getDateFormat } = clickhouse;
|
||||
const params = [websiteId];
|
||||
const { rawQuery } = clickhouse;
|
||||
const params = { websiteId, startAt: subMinutes(new Date(), 5) };
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_id) x
|
||||
from event
|
||||
where website_id = $1
|
||||
and created_at >= ${getDateFormat(subMinutes(new Date(), 5))}`,
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startAt:DateTime('UTC')}`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue