Conversation
…eir career page matchResult() only checked for a missing faction, so a session's most recent poll landing on the game's own pre-pick value sailed through as a real competitor and lost against whatever team actually won. Caught on a live server: a player who won every match that night had every one of them recorded as a loss under faction "White", because their session was mid-pick for the current match when the career page's query ran. The same CASE is duplicated in leaderboards.ts for the board aggregates, so this was silently wrong there too, not just on the career page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J3PtgLmN9qBFjAk1LwsnfM
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.
What's broken
matchResult()only checks whether a player has a faction, not whether thatfaction was actually one of the match's competing teams. A player's
player_sessions.factionis overwritten on every poll tick, so it only everreflects their most recent observed faction — including the game's own
holding-team value,
"White", for a player who hasn't been put on a side yet(between matches, or mid-pick for the one in progress).
Since
"White"is a truthy string, it sails past the!factioncheck andgets compared directly against the match winner, which it never equals — so
it always resolves to a loss.
Caught on a live server: a player who won every match that night saw every
one of them recorded as a loss on their career page, because their session
happened to read
"White"(mid-pick for the current, in-progress match) atthe moment the career query ran — and that one current value gets joined to
every match the session spans, including ones from earlier the same night
that they actually played and won.
This isn't just a career-page cosmetic bug:
src/lib/server/leaderboards.tsduplicates the same
CASEfor the board aggregates (explicitly commented asmirroring
matchResult()), so it was silently corrupting the win-rateleaderboard too, for anyone who has ever had a
"White"tick land as theirsession's latest value.
Fix
Treat the holding team the same way the public live page already does (see
its "Unassigned" row /
isTeamcheck): never a competitor, so never a winneror a loss. Added
HOLDING_TEAMinsrc/lib/leaderboard.tsand mirrored thesame exclusion into the SQL
CASEinleaderboards.ts, plus a test casereproducing the exact scenario.
Testing
bun test src/lib/leaderboard.test.ts— 15 pass, including the new case.Full suite: 392 pass, 213 skip (DB-dependent), 16 fail — all 16 are
pre-existing Windows path-separator mismatches in
page-loads.test.ts/api-matrix.test.ts/load-matrix.test.ts, unrelated to this change andpresent before it on a clean checkout.
🤖 Generated with Claude Code