Skip to content

Commit

Permalink
fix: abandoned traffic sites calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Jan 6, 2025
1 parent 0e5ea33 commit 1e5af60
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions backend/apps/cloud/src/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 1e5af60

Please sign in to comment.