feat(api): add wavelog /api/statistics and /api/version stubs#205
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unblocks GridTracker (and similar Cloudlog-flavored clients) that pre-flight an API key by hitting
/api/statisticsbefore sending any QSOs. Without this endpoint, GT hangs at "Testing API Key" because it never gets a parseable response. Also adds/api/versionsince some GT builds probe it instead/additionally.POST /api/statistics{ key }{ Today, total_qsos, month_qsos, year_qsos }{ status, reason }POST /api/version{ key }{ status: 'ok', version: '2.7.0' }{ status, reason }Counts in
/api/statisticsare computed in a single PostgresFILTERaggregate overcontacts— one round-trip, no N+1. Day/month/year boundaries are anchored to UTC viadate_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_idis 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.0to match what/api/cloudlogalready 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-onlysnapshot of the production schema, with two seed QSOs.npm run typecheckcleannpm run lintcleanPOST /api/statisticswith valid key →{Today:2, total_qsos:2, month_qsos:2, year_qsos:2}(matches DB row count)POST /api/statisticswith bad key → 401{status:"failed", reason:"missing or invalid api key"}POST /api/versionwith valid key →{status:"ok", version:"2.7.0"}POST /api/versionwith bad key → 401{status:"failed", reason:"missing or invalid api key"}Deploy
No migration needed — purely additive read-only endpoints. After merge + deploy, GT (and similar) should validate cleanly.
🤖 Generated with Claude Code