Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: abandoned traffic sites calculation

Blue Mouse1e5af605ca93
diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.ts
index 1074d11c5..35f7d0455 100644
--- a/backend/apps/cloud/src/project/project.service.ts
+++ b/backend/apps/cloud/src/project/project.service.ts
@@ -1866,15 +1866,18 @@ export class ProjectService {
`
} else if (options.mode === 'lost-traffic') {
query = `
- SELECT
- pid,
- max(created) as last_visit,
- count() as total_visits
- FROM analytics
- WHERE pid IN {pids:Array(String)}
- AND created < (now() - INTERVAL 48 HOUR)
- GROUP BY pid
- HAVING last_visit < (now() - INTERVAL 48 HOUR)
+ WITH last_visits AS (
+ SELECT
+ pid,
+ max(created) as last_visit,
+ count() as total_visits
+ FROM analytics
+ WHERE pid IN {pids:Array(String)}
+ GROUP BY pid
+ )
+ SELECT *
+ FROM last_visits
+ WHERE last_visit < (now() - INTERVAL 48 HOUR)
AND total_visits > 0
ORDER BY last_visit DESC
LIMIT {limit:UInt32}