Uh oh!
There was an error while loading. Please reload this page.
Fix leaderboard live updates across connection and bingo flows - #122
Merged
Conversation
- Extract emitLeaderboardUpdate helper that recomputes a participant's
connectionsCount and emits a full Pusher payload, replacing duplicated
inline blocks in updateScore and createParticipantConnection.
- Fix createParticipantConnectionByEmails and deleteParticipantConnection,
which previously emitted empty {} payloads that the web client silently
dropped, causing the leaderboard to miss link/unlink events.
- Mirror backend sort tiebreakers in the web Leaderboard component
(completed, then linesCompleted, then connectionsCount).
- Wire mobile NameBingo handleAssign to PUT /leaderboard/score after each
square assignment so linesCompleted and the blackout completed flag
propagate to the live leaderboard.
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 freeto 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
The leaderboard was not updating live for several state changes. After tracing the Pusher path end-to-end, three classes of bugs were fixed plus the missing mobile wiring for bingo line completion.
Bugs fixed
pusher.trigger(..., \"leaderboard-updated\", {}). The web client's handler checkspayload.participantIdandpayload.connectionsCount, both undefined on an empty payload, and falls into its drop branch — so the leaderboard silently ignored the event. Now both endpoints emit a full payload per affected participant.Leaderboard.tsxsorted only byconnectionsCount, while the backend GET sorts by(completed, linesCompleted desc, connectionsCount desc). After live updates, the order would diverge from a refresh. Frontend sort now mirrors the backend.PUT /leaderboard/score, solinesCompletedwas stuck at 0 in practice. Mobile'shandleAssignnow fires the score update (with the blackoutcompletedflag) after each assignment.Refactor
Extracted
emitLeaderboardUpdate(eventId, participantId)helper. It recomputes the participant'sconnectionsCount, emits the full payload toevent-{eventId}, and logs Pusher errors instead of throwing — so a flaky Pusher call can't 500 the originating request. Replaced four inline emit blocks with helper calls.Files
Verification
Backend was exercised end-to-end against a local stack:
Test plan