mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
Merge c924ef8582 into 860e6390f1
This commit is contained in:
commit
e7a8c3e1a9
1 changed files with 20 additions and 20 deletions
|
|
@ -36,11 +36,11 @@ async function relationalQuery(
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
count(*) as "pageviews",
|
count(*) filter (where website_event.event_type = 1) as "pageviews",
|
||||||
count(distinct website_event.session_id) as "visitors",
|
count(distinct website_event.session_id) filter (where website_event.event_type = 1) as "visitors",
|
||||||
count(distinct website_event.visit_id) as "visits",
|
count(distinct website_event.visit_id) filter (where website_event.event_type = 1) as "visits",
|
||||||
count(distinct session.country) as "countries",
|
count(distinct session.country) filter (where website_event.event_type = 1) as "countries",
|
||||||
sum(case when website_event.event_type = 2 then 1 else 0 end) as "events"
|
count(*) filter (where website_event.event_type = 2) as "events"
|
||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
join session on website_event.session_id = session.session_id
|
join session on website_event.session_id = session.session_id
|
||||||
|
|
@ -67,30 +67,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, queryParams, FUNCTION_NAME);
|
return rawQuery(sql, queryParams, FUNCTION_NAME);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue