feat(stats): add counter-backed usage and trending stats#746
Open
camathieu wants to merge 1 commit into
Open
Conversation
0264125 to
23342fe
Compare
Add DB-backed usage counters for users, tokens, and server-wide stats, including current and lifetime upload/file/size totals, feature usage, TTL distributions, download counters, and daily download rollups. Expose the new stats through user, token, admin, metrics, and trending APIs, update the Vue admin/home/download views, and add sorting by stats-backed size/download fields. Keep stats safe for multi-instance deployments with atomic metadata mutations, import/export coverage, bounded daily rollup cleanup, and best-effort download stat writes that do not block valid downloads. Document the stats architecture, cleanup semantics, download counting policy, Prometheus metrics, API fields, and agent review expectations.
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.
Description
What
Adds backend Stats V1 with DB-backed usage counters, download counters, daily rollups, and admin trending endpoints.
Why
The previous stats path relied on aggregate queries and did not support current vs lifetime usage, trending downloads, token usage stats, or multi-instance-safe counter updates.
Changes
user_usage_stats,server_usage_stats,token_usage_stats, anddownload_stats_daily.startedAt.lastDownloadedAt./me/statsand/statsresponse fields.0011-statsmigration dumps.Testing
git diff --checkmake lintmake client serverNO_RACE=1 make testmake testmake docsmake test-backendspassed on rerunmake vulncompleted, with existing Go 1.26.1 stdlib and npm audit findings reported