chore: add (leaderboard_id, deleted_at, score) index to leaderboard_entries#5043
Merged
wescopeland merged 2 commits intoJul 10, 2026
Merged
Conversation
Contributor
Confidence Score: 5/5Safe to merge — online DDL with no locking, straightforward index addition. Simple, additive migration using non-blocking online DDL. No data modification, no schema breaking changes. No files require special attention. Reviews (2): Last reviewed commit: "Merge branch 'master' into leaderboard-e..." | Re-trigger Greptile |
Jamiras
approved these changes
Jul 7, 2026
wescopeland
enabled auto-merge (squash)
July 10, 2026 21:38
wescopeland
added a commit
that referenced
this pull request
Jul 10, 2026
… entries (#5045) Accompanies #5043. This PR adds a user-scoped leaderboard entries relationship endpoint that supports a `gameId` filter. This is intended to allow clean migration from API_GetUserGameLeaderboards. ``` GET /api/v2/users/{user}/leaderboard-entries GET /api/v2/users/{user}/leaderboard-entries?filter[gameId]=1,2,3 GET api/v2/users/{user}/leaderboard-entries?include=leaderboard.games ``` **Things worth noting:** 1. Each entry's `rank` is computed with a correlated subquery mirroring V1's `calculated_rank`, since a user's entries span many leaderboards. The subquery leans on the index added in #5043. 2. The subquery excludes untracked users in rank calculations. 3. GETs against untracked users (`{user}`) return an empty list. 4. Hidden leaderboards, hub/event games, and soft-deleted leaderboards/entries are excluded, consistent with `/leaderboards/{id}/entries`. 5. `filter[gameId]` is comma-delimited. 6. Default sort is leaderboard ID ascending. 7. `?include=leaderboard.games` is allowed for tying entries back to games. Include paths are listed explicitly rather than via `maxDepth: 2`. The plural `games` is intentional and matches the existing `leaderboards` resource - anticipating that leaderboards can potentially be attached to multiple games/sets per leaderboard ID.
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.
Pre-req for V2 API stuff. It's desirable to have a user leaderboard entries relation endpoint that displays ranks, but unless we have this index, the query from a cold cache hit is slow enough to be a potential DoS vector.
The index on my local occupies roughly 540MB of space.