Files
FTL/test/api
010011110 92bb3afb94 Use the shared status sets in /api/stats/database/upstreams
The endpoint counted "cache" as `status = 3` only, "blocklist" as
`status NOT IN (0,2,3)`, and the per-upstream counts as every row with a
forward id. CACHE_STALE rows (17) therefore landed under "blocklist"
instead of "cache", RETRIED (12), RETRIED_DNSSEC (13) and IN_PROGRESS (14)
rows were reported as blocked, and an EXTERNAL_BLOCKED_* row, which keeps
its upstream for the record, was counted both under that upstream and
under "blocklist", so total_queries exceeded sum_queries of
`/api/stats/database/summary` for the same range.

Use the same sets as `is_blocked()`, `is_cached()` and `is_forwarded()`:
"cache" is `status IN (3,17)`, "blocklist" is FILTER_STATUS_BLOCKED, and
an upstream is credited with its `status IN (2,12,13)` rows only, which
is what the in-memory upstream counters hold. total_queries is now the
plain count over the range, as the summary endpoint reports it, and
forwarded_queries the sum of the upstream counts.

The upstream rows are also joined against `forward_by_id`, since
`query_storage.forward` holds the id of that table and the endpoint
returned it verbatim as the "ip" (`{"ip":"1","port":-1}`) instead of the
address and port.

Signed-off-by: 010011110 <duckenheim@posteo.de>
2026-09-22 07:44:18 +02:00
..
…
…