Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix relational queries for new screens

Francis Cao7ae3c790cd29
diff --git a/src/queries/analytics/events/getEventDataProperties.ts b/src/queries/analytics/events/getEventDataProperties.ts
index 8d1eaf9de..9d55f8967 100644
--- a/src/queries/analytics/events/getEventDataProperties.ts
+++ b/src/queries/analytics/events/getEventDataProperties.ts
@@ -24,14 +24,15 @@ async function relationalQuery(
return rawQuery(
`
select
- event_name as "eventName",
- data_key as "propertyName",
+ we.event_name as "eventName",
+ ed.data_key as "propertyName",
count(*) as "total"
- from event_data
- where website_id = {{websiteId::uuid}}
- and created_at between {{startDate}} and {{endDate}}
+ from event_data ed
+ join website_event we on we.event_id = ed.website_event_id
+ where ed.website_id = {{websiteId::uuid}}
+ and ed.created_at between {{startDate}} and {{endDate}}
${filterQuery}
- group by event_name, data_key
+ group by we.event_name, ed.data_key
order by 3 desc
limit 500
`,
diff --git a/src/queries/analytics/sessions/getWebsiteSessionStats.ts b/src/queries/analytics/sessions/getWebsiteSessionStats.ts
index a3130c7c3..5660a5fa2 100644
--- a/src/queries/analytics/sessions/getWebsiteSessionStats.ts
+++ b/src/queries/analytics/sessions/getWebsiteSessionStats.ts
@@ -29,10 +29,10 @@ async function relationalQuery(
`
select
count(*) as "pageviews",
- count(distinct t.session_id) as "visitors",
- count(distinct t.visit_id) as "visits",
- count(distinct t.country) as "countries",
- sum(case when event_type = 2 then 1 else 0 end) as "events"
+ count(distinct website_event.session_id) as "visitors",
+ count(distinct website_event.visit_id) as "visits",
+ count(distinct session.country) as "countries",
+ sum(case when website_event.event_type = 2 then 1 else 0 end) as "events"
from website_event
join session on website_event.session_id = session.session_id
where website_event.website_id = {{websiteId::uuid}}
diff --git a/src/queries/analytics/sessions/getWebsiteSessionsWeekly.ts b/src/queries/analytics/sessions/getWebsiteSessionsWeekly.ts
index 9031edf51..c92c2929b 100644
--- a/src/queries/analytics/sessions/getWebsiteSessionsWeekly.ts
+++ b/src/queries/analytics/sessions/getWebsiteSessionsWeekly.ts
@@ -21,7 +21,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
select
${getDateWeeklySQL('created_at')} as time,
count(distinct session_id) as value
- from website_event_stats_hourly
+ from website_event
where website_id = {{websiteId::uuid}}
and created_at between {{startDate}} and {{endDate}}
group by time