mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
fix: align clickhouse with prisma query
This commit is contained in:
parent
b8b773a402
commit
c924ef8582
1 changed files with 15 additions and 15 deletions
|
|
@ -62,30 +62,30 @@ async function clickhouseQuery(
|
||||||
sql = `
|
sql = `
|
||||||
select
|
select
|
||||||
sumIf(1, event_type = 1) as "pageviews",
|
sumIf(1, event_type = 1) as "pageviews",
|
||||||
uniq(session_id) as "visitors",
|
uniqIf(session_id, event_type = 1) as "visitors",
|
||||||
uniq(visit_id) as "visits",
|
uniqIf(visit_id, event_type = 1) as "visits",
|
||||||
uniq(country) as "countries",
|
uniqIf(country, event_type = 1) as "countries",
|
||||||
sum(length(event_name)) as "events"
|
sumIf(1, event_type = 2) as "events"
|
||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
sql = `
|
sql = `
|
||||||
select
|
select
|
||||||
sum(views) as "pageviews",
|
sumIf(views, event_type = 1) as "pageviews",
|
||||||
uniq(session_id) as "visitors",
|
uniqIf(session_id, event_type = 1) as "visitors",
|
||||||
uniq(visit_id) as "visits",
|
uniqIf(visit_id, event_type = 1) as "visits",
|
||||||
uniq(country) as "countries",
|
uniqIf(country, event_type = 1) as "countries",
|
||||||
sum(length(event_name)) as "events"
|
sumIf(1, event_type = 2) as "events"
|
||||||
from website_event_stats_hourly website_event
|
from website_event_stats_hourly website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawQuery(sql, params);
|
return rawQuery(sql, params);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue