refactor(queries): replace hardcoded event types with constants
Replaced hardcoded `event_type` values with named constants from `EVENT_TYPE`, as in #3614. Added the `BOUNCE_THRESHOLD` constant and documented it in `docker-compose.yml`.
This commit is contained in:
1 parent
9b41053d47
commit
19fcde2c9c
6 files changed
+20
-15
No files matched your search
@@ -50,8 +50,8 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||
min(website_event.created_at) as "firstAt",
|
||||
max(website_event.created_at) as "lastAt",
|
||||
count(distinct website_event.visit_id) as "visits",
|
||||
sum(case when website_event.event_type = 1 then 1 else 0 end) as "views",
|
||||
sum(case when website_event.event_type = 2 then 1 else 0 end) as "events",
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.pageView} then 1 else 0 end) as "views",
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.customEvent} then 1 else 0 end) as "events",
|
||||
max(website_event.created_at) as "createdAt"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -125,8 +125,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
${getDateStringSQL('min(created_at)')} as firstAt,
|
||||
${getDateStringSQL('max(created_at)')} as lastAt,
|
||||
uniq(visit_id) as visits,
|
||||
sumIf(1, event_type = 1) as views,
|
||||
sumIf(1, event_type = 2) as events,
|
||||
sumIf(1, event_type = ${EVENT_TYPE.pageView}) as views,
|
||||
sumIf(1, event_type = ${EVENT_TYPE.customEvent}) as events,
|
||||
max(created_at) as createdAt
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -155,7 +155,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
${getDateStringSQL('min(min_time)')} as firstAt,
|
||||
${getDateStringSQL('max(max_time)')} as lastAt,
|
||||
uniq(visit_id) as visits,
|
||||
sumIf(views, event_type = 1) as views,
|
||||
sumIf(views, event_type = ${EVENT_TYPE.pageView}) as views,
|
||||
sum(length(event_name)) as events,
|
||||
max(max_time) as createdAt
|
||||
from website_event_stats_hourly as website_event
|
||||
|
||||
Reference in new issue
Block a user