Skip to content

feat(backend): add online player count and rating history endpoints (BE-125) - #1539

Open
davidluxedesigns wants to merge 1 commit into
OpenKnight-Foundation:mainfrom
davidluxedesigns:feat/be-125-player-stats-endpoints
Open

davidluxedesigns wants to merge 1 commit into
OpenKnight-Foundation:mainfrom
davidluxedesigns:feat/be-125-player-stats-endpoints

Conversation

@davidluxedesigns

Copy link
Copy Markdown

Summary

Adds two player-stats endpoints the frontend needs: a public online-player count for the home page and per-player rating history for the dashboard.

Closes #1392

Changes

  • GET /v1/players/online: public; returns the number of distinct players with an active connection, taken from connection tracking
  • GET /v1/players/{id}/rating-history?range=7d|30d|90d|1y|all: rating over time derived from completed games only, ordered oldest to newest; defaults to 30d
  • Invalid range returns 400, unknown player returns 404
  • Response size is capped to keep the endpoint bounded
  • [Index migration / API docs updated, delete whichever doesn't apply]

Testing

  • Added tests for online count (zero, multi-tab dedupe, no auth needed)
  • Added tests for rating history (completed games only, ordering, range filtering, default range, 400, 404, cap)
  • cargo fmt, cargo clippy -- -D warnings and cargo test pass locally

Notes

  • Frontend wiring (frontend/app/page.tsx, frontend/app/dashboard/page.tsx) is out of scope for this PR and can follow separately.

This branch has not been deployed

No deployments
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.

BE-125: Add Player Stats Endpoints: Online Count and Rating History

1 participant