-
Notifications
You must be signed in to change notification settings - Fork 1
Fix community race leaderboard showing DNF players #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| "lateral".players | ||
| FROM team_pantheon_custom_race_leaderboard | ||
| LEFT JOIN LATERAL ( | ||
| SELECT | ||
| SELECT | ||
| JSONB_AGG( | ||
| JSONB_BUILD_OBJECT( | ||
| 'membershipId', membership_id::text, | ||
|
|
@@ -34,11 +34,11 @@ | |
| 'isPrivate', is_private, | ||
| 'cheatLevel', cheat_level | ||
| ) | ||
| ORDER BY instance_player.completed DESC, instance_player.time_played_seconds DESC | ||
| ) as "players" | ||
| FROM instance_player | ||
| INNER JOIN player USING (membership_id) | ||
| WHERE instance_player.instance_id = team_pantheon_custom_race_leaderboard.instance_id | ||
| AND instance_player.completed | ||
| ) as "lateral" ON true | ||
| WHERE position > $1 AND position <= ($1 + $2) | ||
| ORDER BY position ASC`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: A temporal inconsistency between deployment and a SQL migration causes searches for DNF players to return their team but omit them from the player list, breaking tests. Suggested FixThe issue is caused by a temporary desynchronization between the search index and the query filter. The documented solution is to run the companion SQL migration immediately after API deployment to update the Prompt for AI Agent |
||
|
|
@@ -71,12 +71,12 @@ | |
| ) | ||
| if (!result) return null | ||
|
|
||
| const page = Math.ceil(result.position / take) | ||
| return { | ||
| page, | ||
| entries: await getPantheonCustomRaceTeamLeaderboard({ | ||
| skip: (page - 1) * take, | ||
| take | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The
JSONB_AGGforplayerscan returnNULLif all players in an entry are filtered out, but the Zod schema expects an array, causing a validation error.Severity: HIGH
Suggested Fix
Wrap the
JSONB_AGG(...)call in the SQL query withCOALESCE(JSONB_AGG(...), '[]'::jsonb). This ensures that if no players match the filter, an empty array[]is returned instead ofNULL, satisfying the Zod schema and preventing validation errors.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.