Sum top winner across all game modes on home page#143
Open
dhoepp wants to merge 2 commits into
Open
Conversation
The leaderboard table has one row per (user_id, mode), so the home page's "top winner" stat was only ever reading infinity-mode rows and missing hourly/daily play entirely. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🤖 AI Review (Gemini 2.5 Flash)This PR introduces a new |
Addresses PR review feedback: - Aggregating all leaderboard rows client-side doesn't scale as the table grows. Added a get_top_winner() RPC (same SECURITY DEFINER aggregate-read pattern as get_global_game_stats) that does the per-user GROUP BY in Postgres and returns only the winner. - The client-side aggregation kept whichever username it saw first for a user, which could be stale if they renamed themselves between mode rows. The RPC now picks the username from the most recently updated row. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dhoepp
enabled auto-merge
July 21, 2026 12:53
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.
Summary
fetchLeaderboard("infinity"), which filters theleaderboardtable tomode = 'infinity'— hourly and daily play were never counted.leaderboardtable has one row per(user_id, mode), so there's no single row to query for an overall winner; addedfetchTopWinner()inleaderboard.tswhich fetches all rows (no mode filter) and aggregatesgames_played/games_won/scoreperuser_idclient-side, then picks the top by score (tie-broken by games_won) — same orderingfetchLeaderboardalready used.LandingFeatures.tsxto usefetchTopWinner()instead.Reviewer notes
fetchLeaderboard(mode)and the Leaderboard page's per-mode tabs are untouched — this only changes the home page widget.Test plan
npx tsc --noEmitinfrontend/(no new errors from this change)