Repository navigation
Add public stats endpoint for DanielIbarra.com - #59
Merged
Merged
Conversation
GET /api/public/stats returns live, anonymous Aviary totals for the portfolio's Aviary panel: users, aircraft, flights, hours flown (time in service), alerts sent, signups in the last 7/30 days, and up to 10 date-only "New pilot joined" lines. Nothing about any one account. - Public, read-only filter chain for /api/public/**: no login, no session, GET only. CORS only for aviary.public-stats.allowed-origins (env AVIARY_PUBLIC_STATS_ORIGINS, defaults to danielibarra.com). - Rate limited to 60 calls per IP per 10 minutes (429 + Retry-After). - Numbers are cached for 15 minutes and recomputed only on request, one thread at a time, so traffic never turns into per-visitor queries and nothing wakes Neon on a timer. A failed refresh keeps serving the last snapshot; 503 only if none exists yet. - users.created_at (nullable, set by @PrePersist) records signup dates from now on. Existing accounts stay NULL: no guessed dates. Additive; migration note in docs/migrations. - All accounts are counted for now, test accounts included. - Tests: service caching and shaping, real queries on H2, and endpoint checks (public, no session, CORS allow/deny, POST refused, 429, and no username or tail number in the body). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M4dsGvpqnWiNuLHPLuGXx4
Linux clocks give nanosecond Instants but the database keeps microseconds, so a freshly saved account's createdAt didn't match what was read back (failed in CI, passed on macOS). Truncate when it's set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M4dsGvpqnWiNuLHPLuGXx4
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.
What
GET /api/public/stats: live, anonymous Aviary totals for the new[ LIVE STATS ]panel on danielibarra.com. It returns users, aircraft, flights, hours flown, alerts sent, signups in the last 7 and 30 days, and up to 10 date-only "New pilot joined" lines. Nothing about any one account.How
/api/public/**. No login, no session, GET only. CORS is allowed only fordanielibarra.com(AVIARY_PUBLIC_STATS_ORIGINS). Other origins and POST get403.429.users.created_at, set on first save. Existing accounts stayNULL(no guessed dates). Additive; the note is indocs/migrations/2026-11-09_users_created_at.sql.Tests
./gradlew testpasses.After merge
mainauto-deploys to staging.https://<staging>/api/public/stats, then promote to production.