feat(stats): track ROM downloads and add an admin statistics tab - #4087
Open
bikeborb wants to merge 3 commits into
Open
feat(stats): track ROM downloads and add an admin statistics tab#4087bikeborb wants to merge 3 commits into
bikeborb wants to merge 3 commits into
Conversation
Adds a `download_events` audit log plus denormalized per-ROM counters, so an operator can see what is actually being downloaded and identify content nobody uses. - New `download_events` table: user, ROM, platform, source, kind, byte count, client IP and user agent, with name snapshots so a row survives the deletions it exists to inform. - `roms.download_count` / `roms.last_downloaded_at`, incremented in SQL so concurrent downloads of the same ROM cannot lose an increment. - Recording hooks on the single-ROM, single-file and bulk-zip download endpoints. Inline media (soundtracks, manuals) is excluded, so opening a game page does not inflate its count. - `HybridAuthBackend` records how a request authenticated, which is what distinguishes a WebUI download from an API client. - Admin-gated `/api/stats/downloads` endpoints and a Downloads tab in the existing Administration page. - Optional retention via `DOWNLOAD_EVENTS_RETENTION_DAYS`, off by default. Recording is best-effort and never fails a download. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Author
|
Following the feedback that this diff is too large, and after re-reading
I'll open those once there's a steer on #4089, so please don't spend |
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gantoine
self-requested a review
August 4, 2026 01:19
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.
Adds a
download_eventsaudit log plus denormalized per-ROM counters, so an operator can see what is actually being downloaded and identify content nobody uses.download_eventstable: user, ROM, platform, source, kind, byte count, client IP and user agent, with name snapshots so a row survives the deletions it exists to inform.roms.download_count/roms.last_downloaded_at, incremented in SQL so concurrent downloads of the same ROM cannot lose an increment.HybridAuthBackendrecords how a request authenticated, which is what distinguishes a WebUI download from an API client./api/stats/downloadsendpoints and a Downloads tab in the existing Administration page.DOWNLOAD_EVENTS_RETENTION_DAYS, off by default.Recording is best-effort and never fails a download.
Description
Explain the changes or enhancements you are proposing with this pull request.
Checklist
Please check all that apply.
Screenshots (if applicable)