Skip to content

feat(stats): add counter-backed usage and trending stats#746

Open
camathieu wants to merge 1 commit into
masterfrom
improved-stats
Open

feat(stats): add counter-backed usage and trending stats#746
camathieu wants to merge 1 commit into
masterfrom
improved-stats

Conversation

@camathieu
Copy link
Copy Markdown
Member

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

  • Add user_usage_stats, server_usage_stats, token_usage_stats, and download_stats_daily.
  • Track current and lifetime uploads/files/size, including anonymous usage and startedAt.
  • Add upload/file download counters and lastDownloadedAt.
  • Count file downloads with range-aware policy: full GETs and byte-0 range GETs only.
  • Record archive downloads after archive close, counting the upload once and each included file once.
  • Add admin trending endpoints for uploads and files.
  • Extend /me/stats and /stats response fields.
  • Export/import daily download rollups and regenerate 0011-stats migration dumps.
  • Add metadata, handler, concurrency, and e2e coverage.

Testing

  • git diff --check
  • make lint
  • make client server
  • NO_RACE=1 make test
  • make test
  • make docs
  • make test-backends passed on rerun
  • make vuln completed, with existing Go 1.26.1 stdlib and npm audit findings reported

@camathieu camathieu force-pushed the improved-stats branch 11 times, most recently from 0264125 to 23342fe Compare May 1, 2026 10:38
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.
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