mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-10-23 14:32:32 +00:00
fix(observers): separate packet metrics from presence updates
This commit is contained in:
1 parent
fd7c6b3eb7
commit
5fbba24a4a
31 files changed
+844
-93
No files matched your search
@@ -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;
|
||||
Reference in new issue
Block a user