Repository navigation
Break leaderboard ties by entry time and highlight the leader - #27
Merged
Merged
Conversation
Equal scores used to share a rank, and the live board has a three-way tie for first at 3,250. leaderboard() now gives every drink its own place: score first, then the earliest createdAt (admission time on the service, serve time at a booth), then drink ID for a same-millisecond tie. Every stored entry already has createdAt, so the live board settles on redeploy with no reset or rescore. Booths only check a receipt's rank is a positive integer, so they keep working against the new service. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A tied top score goes to the drink that reached the board first, so the public page now marks first place with a Leader badge and shows when that drink was entered. GET /api/board adds a top-level leaderEnteredAt (null on an empty board); rows still carry no timestamps, so no other drink's time is published. Booths read only boardId, captured, rebuilding, and total, so they need no update. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical concurrency issue allows timestamps assigned before serialized admission to misorder drink rankings across service instances, requiring timestamp assignment under the shared lock and a regression test.
1 open issue
What changed in this PR
This PR replaces shared ranks with entry-time tie-breaking in the shared leaderboard logic and highlights first place on the public board.
Changes:
- Rank drinks by score, then entry time and drink ID, assigning each a unique place.
- Publish only the leader’s entry time and add a Leader badge with accessible styling.
- Update attendee guidance and tests for ranking, API output, rendering, and contrast.
| File | Description |
|---|---|
tests/leaderboard-service.test.mjs |
Tests tie-breaking, leader timestamps, rendering, and contrast. |
tests/booth-menu.test.mjs |
Tests unique ranks and deterministic tie-breaking. |
leaderboard-service/public/board.js |
Displays the leader badge, entry time, and updated caption. |
leaderboard-service/public/board.css |
Styles the leader while preserving personal-row highlighting. |
leaderboard-service/app.mjs |
Adds leaderEnteredAt to the public board response. |
docs/learner-guide.md |
Explains entry-time tie-breaking to attendees. |
docs/leaderboard-service.md |
Documents ranking, rebuild behavior, and the API field. |
docs/integration-contract.md |
Defines booth and service tie-breaking semantics. |
booth/RUNBOOK.md |
Updates staff guidance on local and event ranks. |
.github/steps/1-name-a-drink.md |
Updates learner instructions for tied scores. |
.github/skills/order-up/SKILL.md |
Aligns booth-session guidance with the new ranking rule. |
.github/extensions/commit-and-sip/services/booth-menu.mjs |
Implements score, timestamp, and ID ordering with unique ranks. |
Review effort: Balanced
The service stamped createdAt before FileStore.admit took the write lock, so a request that waited for another instance's write could be admitted second but carry the earlier time and win the tie. The store now stamps the time inside admit, under the lock, never earlier than the latest drink already on the board, so entry order matches admission order even when instance clocks disagree. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
createdAt), then by drink ID, so every drink gets its own rank. The live board currently has four drinks tied at 4,600.GET /api/boardgains a top-levelleaderEnteredAtfield (null on an empty board). Rows still carry no timestamps, so only the leader's time is published.Compatibility and data
boardId,captured,rebuilding, andtotal, andname-score.mjsis unchanged, so booths need no update.createdAt, so the existing board re-ranks on deploy without a reset./home/datauntouched.Accessibility
textContent, so the CSP is unchanged.Tests
npm test: 333/333 pass. New tests cover:A mutation check showed the tests catch a badge applied beyond first place.
Checked visually at desktop and phone widths against a local service seeded with a four-way tie.