fix(observers): separate packet metrics from presence updates

This commit is contained in:
n30nex authored and MrAlders0n committed 2026-09-30 07:19:02 -04:00
1 parent fd7c6b3eb7
commit 5fbba24a4a
31 files changed
+844 -93

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
-- name: GetObserverActivityLiveSummary :one
-- Two indexed ranges, bounded to one observer; no legacy presence counters.
WITH latest AS (
SELECT heard_at FROM packet_observations
WHERE observer_id = @observer_id::uuid AND heard_at <= @generated_at::timestamptz
ORDER BY heard_at DESC LIMIT 1
), hourly AS (
SELECT COUNT(*)::bigint AS n FROM packet_observations
WHERE observer_id = @observer_id::uuid
AND heard_at >= @hour_start::timestamptz AND heard_at < @hour_end::timestamptz
)
SELECT (SELECT heard_at FROM latest)::timestamptz AS latest_recorded_at,
hourly.n AS last_complete_hour FROM hourly;