Skip to content

feat(api): add wavelog /api/statistics and /api/version stubs#205

Merged
patrickrb merged 1 commit into
mainfrom
feat/wavelog-statistics-version
May 11, 2026
Merged

feat(api): add wavelog /api/statistics and /api/version stubs#205
patrickrb merged 1 commit into
mainfrom
feat/wavelog-statistics-version

Conversation

@patrickrb
Copy link
Copy Markdown
Owner

Summary

Unblocks GridTracker (and similar Cloudlog-flavored clients) that pre-flight an API key by hitting /api/statistics before sending any QSOs. Without this endpoint, GT hangs at "Testing API Key" because it never gets a parseable response. Also adds /api/version since some GT builds probe it instead/additionally.

Endpoint Body Success Failure
POST /api/statistics { key } 200 { Today, total_qsos, month_qsos, year_qsos } 401 { status, reason }
POST /api/version { key } 200 { status: 'ok', version: '2.7.0' } 401 { status, reason }

Counts in /api/statistics are computed in a single Postgres FILTER aggregate over contacts — one round-trip, no N+1. Day/month/year boundaries are anchored to UTC via date_trunc('day'/'month'/'year', CURRENT_TIMESTAMP AT TIME ZONE 'UTC') so the values match what UTC-displaying clients expect.

Both endpoints respect the per-key station scoping the rest of the wavelog endpoints honor — if api_keys.station_id is set, the counts and version are scoped to that station's data (no cross-station leakage from a single-station API key).

The version string reports 2.7.0 to match what /api/cloudlog already claims as the wavelog compatibility target. Clients use this to decide which features to enable; lying about it would degrade their behavior.

Test plan

Tested locally against a postgres container loaded with a pg_dump --schema-only snapshot of the production schema, with two seed QSOs.

  • npm run typecheck clean
  • npm run lint clean
  • POST /api/statistics with valid key → {Today:2, total_qsos:2, month_qsos:2, year_qsos:2} (matches DB row count)
  • POST /api/statistics with bad key → 401 {status:"failed", reason:"missing or invalid api key"}
  • POST /api/version with valid key → {status:"ok", version:"2.7.0"}
  • POST /api/version with bad key → 401 {status:"failed", reason:"missing or invalid api key"}
  • After deploy: GridTracker no longer hangs at "Testing API Key" and successfully validates the connection

Deploy

No migration needed — purely additive read-only endpoints. After merge + deploy, GT (and similar) should validate cleanly.

🤖 Generated with Claude Code

GridTracker (and several Cloudlog-flavored clients) pre-flight an API
key by hitting /api/statistics — and some additionally probe
/api/version. Without these endpoints the key validation hangs at
"Testing API Key" because GT never gets a parseable response.

POST /api/statistics  { key } → 200 { Today, total_qsos, month_qsos, year_qsos }
POST /api/version     { key } → 200 { status: 'ok', version: '2.7.0' }

Both 401 with {status,reason} on bad/missing keys. Both respect the
per-key station scoping that the rest of the wavelog endpoints honor
(if api_keys.station_id is set, statistics count only that station's
QSOs). Counts are computed in a single FILTER aggregate against the
contacts table; UTC-anchored boundaries to match how callers display.

The version string reports 2.7.0 to match what /api/cloudlog claims
as the compatibility target — clients enable the same feature set
they'd use against real wavelog at that version.

Tested locally against a postgres container loaded with a snapshot of
the production schema. Two seed QSOs → statistics returns
{Today:2,total_qsos:2,month_qsos:2,year_qsos:2}; bad keys return 401.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodelog Ready Ready Preview, Comment May 11, 2026 6:38pm

Request Review

@patrickrb patrickrb merged commit c5b0c36 into main May 11, 2026
7 checks passed
@patrickrb patrickrb deleted the feat/wavelog-statistics-version branch May 11, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant