feat(stats): serve historical stats from hourly rollups

Stats endpoints read hourly rollup tables filled once per closed hour by one
advisory-locked task, instead of materialized views that re-scanned every
observation on each refresh. IATA-set tables give exact distinct counts for any
IATA set or region. Cleanup holds raw rows for unrolled hours (up to 24h).

Adds /stats/series; ingest keeps packet observation counts, observer last IATA,
channel message counts and trace tag summaries. 001_baseline.sql is rewritten,
so pre-release 2.0 databases must be recreated. See docs/historical-stats.md.
This commit is contained in:
MrAlders0n
2026-10-02 07:43:56 -04:00
committed by MrAlders0n
parent 6cd03e73da
commit 98006a9364
112 changed files with 6766 additions and 2828 deletions
+9
View File
@@ -0,0 +1,9 @@
-- Copyright 2026 Beacon Contributors
-- SPDX-License-Identifier: AGPL-3.0-or-later
-- sqlc type-check stub only; db/rollup.go creates this as a TEMP table per rolled hour.
CREATE TABLE rollup_obs (
packet_hash bytea NOT NULL, observer_id uuid NOT NULL, iata character(3) NOT NULL,
heard_at timestamptz NOT NULL, path_length_byte smallint NOT NULL, hash_size smallint NOT NULL,
hop_count smallint NOT NULL, path_len integer NOT NULL, rssi smallint, snr real, airtime_ms real,
payload_type smallint, route_type smallint NOT NULL, origin_pubkey bytea, scope_id integer);