fix(health): ignore future article timestamps; flag unset vessel/FIRMS keys #59

Merged
sirius merged 1 commit from wt/t_ceb74e64 into master 2026-11-17 19:56:21 +00:00
Owner

Summary

  • /api/health checks.articles.age_s now uses max(timestamp) among rows with timestamp IS NOT NULL AND timestamp <= now(), the same closed window as GET /api/news. Future-dated rows no longer produce a negative age. If every non-null timestamp is in the future, age_s is null and ok is false.
  • GET /api/stats keeps every existing counter (alerts is still nws_alert_count) and adds feeds.vessels.configured / feeds.fires.configured. True only when AISSTREAM_API_KEY or VESSELAPI_API_KEY (vessels) or FIRMS_MAP_KEY (fires) has a non-empty value in the api_keys store. Env vars do not count. The value, a prefix, and the last-4 are not returned.

Test plan

  • pytest tests/test_health_ready.py tests/test_api_stats.py -q — 12 passed, 0 failed
  • Throwaway postgres: fixture row at now+6d and now-120s → age_s in 0..600 (was −518399 before the SQL filter)
  • Throwaway postgres: only a future row plus a NULL timestamp → articles.age_s null, ok false
  • Do not merge from this card. Known-red CI at docker login 127.0.0.1:3000 is not this change.

Child card t_4f334c8b should rebase onto wt/t_ceb74e64 (head 02a9a56) if this PR is still open.

## Summary - `/api/health` `checks.articles.age_s` now uses `max(timestamp)` among rows with `timestamp IS NOT NULL AND timestamp <= now()`, the same closed window as `GET /api/news`. Future-dated rows no longer produce a negative age. If every non-null timestamp is in the future, `age_s` is null and `ok` is false. - `GET /api/stats` keeps every existing counter (`alerts` is still `nws_alert_count`) and adds `feeds.vessels.configured` / `feeds.fires.configured`. True only when `AISSTREAM_API_KEY` or `VESSELAPI_API_KEY` (vessels) or `FIRMS_MAP_KEY` (fires) has a non-empty value in the `api_keys` store. Env vars do not count. The value, a prefix, and the last-4 are not returned. ## Test plan - [x] `pytest tests/test_health_ready.py tests/test_api_stats.py -q` — 12 passed, 0 failed - [x] Throwaway postgres: fixture row at now+6d and now-120s → `age_s` in 0..600 (was −518399 before the SQL filter) - [x] Throwaway postgres: only a future row plus a NULL timestamp → `articles.age_s` null, `ok` false - [ ] Do not merge from this card. Known-red CI at `docker login 127.0.0.1:3000` is not this change. Child card `t_4f334c8b` should rebase onto `wt/t_ceb74e64` (head `02a9a56`) if this PR is still open.
/api/health articles.age_s used max(timestamp) with no future-date filter,
so rows ahead of now() reported a negative age. Use the same closed window
as the news list (timestamp <= now(); NULL timestamps are not fresh). If
every non-null timestamp is in the future, age_s is null and ok is false.

GET /api/stats keeps existing counters and adds feeds.vessels.configured
and feeds.fires.configured from non-empty api_keys values only. The stored
value is never returned.
sirius merged commit 3f11e647f0 into master 2026-11-17 19:56:21 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/osint-dashboard!59
No description provided.