update dashboard queries to use mv

This commit is contained in:
Francis Cao 2024-07-08 11:18:30 -07:00
parent 5289c277fb
commit bfd5c5f150
5 changed files with 44 additions and 12 deletions

View file

@ -46,6 +46,7 @@ async function clickhouseQuery(
...filters,
eventType: EVENT_TYPE.pageView,
});
const table = unit === 'hour' ? 'website_event_metric_hourly' : 'website_event_metric_daily';
return rawQuery(
`
@ -55,8 +56,8 @@ async function clickhouseQuery(
from (
select
${getDateQuery('created_at', unit, timezone)} as t,
count(distinct session_id) as y
from website_event
uniq(session_id) as y
from ${table} website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type = {eventType:UInt32}