mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Re-write CH queries to use query params.
This commit is contained in:
parent
9a7385e4d5
commit
befc5cf6c0
12 changed files with 114 additions and 125 deletions
|
|
@ -28,14 +28,14 @@ async function relationalQuery(websiteId: string) {
|
|||
}
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ async function clickhouseQuery(
|
|||
const { startDate, endDate, filters = {} } = data;
|
||||
const { rawQuery, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
|
||||
const website = await cache.fetchWebsite(websiteId);
|
||||
const params = [websiteId, website?.revId || 0];
|
||||
const params = { websiteId, revId: website?.revId || 0 };
|
||||
const { filterQuery } = parseFilters(filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -69,8 +69,8 @@ async function clickhouseQuery(
|
|||
max(created_at) max_time
|
||||
from event
|
||||
where event_type = ${EVENT_TYPE.pageView}
|
||||
and website_id = $1
|
||||
and rev_id = $2
|
||||
and website_id = {websiteId:UUID}
|
||||
and rev_id = {revId:UInt32}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${filterQuery}
|
||||
group by session_id, time_series
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue