feat(api): add V2 JSON:API relationship endpoint for user leaderboard entries#5045
Conversation
Confidence Score: 5/5This looks safe to merge.
Reviews (3): Last reviewed commit: "Merge branch 'master' into v2-user-lb-en..." | Re-trigger Greptile |
There was a problem hiding this comment.
Possibly mentioned in previous PR, but is there any value in exposing the created_at field? The updated_at should reflect the last submitted time, but does the first submitted time matter, especially given that we don't have the first submitted value (or anything in-between)?
There was a problem hiding this comment.
I lean towards keeping it here, as it can still be kinda meaningful. Even without the submission history, created_at (obviously) signifies the user's first submitted entry, and it can be compared against updated_at to see the difference between the player's first and best score.
| return [ | ||
| WhereIdIn::make($this)->delimiter(','), | ||
| Scope::make('gameId', 'forGameIds'), | ||
| Scope::make('user', 'forUserIdentifier'), |
There was a problem hiding this comment.
Definitely not something I expect implemented right now, but any plans for a filter on rank? i.e. only show leaderboards where the user is # 1 or in the top ten.
There was a problem hiding this comment.
Seems like a good idea to me.
We could do something like:
- filter[rank]
- filter[maxRank]
I'll track this in my notes.
Accompanies #5043.
This PR adds a user-scoped leaderboard entries relationship endpoint that supports a
gameIdfilter. This is intended to allow clean migration from API_GetUserGameLeaderboards.Things worth noting:
rankis computed with a correlated subquery mirroring V1'scalculated_rank, since a user's entries span many leaderboards. The subquery leans on the index added in chore: add (leaderboard_id, deleted_at, score) index to leaderboard_entries #5043.{user}) return an empty list./leaderboards/{id}/entries.filter[gameId]is comma-delimited.?include=leaderboard.gamesis allowed for tying entries back to games. Include paths are listed explicitly rather than viamaxDepth: 2. The pluralgamesis intentional and matches the existingleaderboardsresource - anticipating that leaderboards can potentially be attached to multiple games/sets per leaderboard ID.