Show game number for Game #2+ in series, hide Game #1 for single-game matchups

If a matchup has only one game (game #1), the number is redundant — show
just the round name. If game #2 or higher is upcoming, it clearly belongs
to a multi-game series, so show the game number to distinguish it.

https://claude.ai/code/session_01CRrqu43FKHshpJt1NyrDdX
This commit is contained in:
Claude 2026-03-22 20:41:19 +00:00
parent 6f51ad8c78
commit 6d6508d503
No known key found for this signature in database
2 changed files with 34 additions and 4 deletions

View file

@ -388,6 +388,24 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
expect(result[0].matchLabel).toBeNull(); expect(result[0].matchLabel).toBeNull();
}); });
it("shows game number when game #2+ is upcoming (multi-game series)", async () => {
const rows = [{
id: "e1", name: "PDC World Championship", eventDate: "2025-04-10",
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
participant1Id: "man-city", participant2Id: "arsenal",
round: "Semifinals", gameNumber: 2, scheduledAt: null,
}];
mockDb.selectDistinct.mockReturnValue(makeSelectChain(rows));
const result = await getUpcomingEventsForDraftedParticipants(
SPORTS_SEASON_ID, "playoff_bracket",
[makeParticipant("man-city", "Man City")],
DATE_FROM, DATE_TO
);
expect(result[0].matchLabel).toBe("Semifinals Game #2");
});
it("all-compete events have null earliestGameTime and matchLabel", async () => { it("all-compete events have null earliestGameTime and matchLabel", async () => {
const participants = [makeParticipant("p1", "Verstappen")]; const participants = [makeParticipant("p1", "Verstappen")];
mockDb.query.scoringEvents.findMany.mockResolvedValue([ mockDb.query.scoringEvents.findMany.mockResolvedValue([

View file

@ -528,10 +528,22 @@ export async function getUpcomingEventsForDraftedParticipants(
// Build matchLabel from game keys // Build matchLabel from game keys
const gameKeys = gameKeysByEvent.get(eventId) ?? new Set<string>(); const gameKeys = gameKeysByEvent.get(eventId) ?? new Set<string>();
if (gameKeys.size >= 1) { if (gameKeys.size === 1) {
// Only show the round name, not game numbers. Game numbers are only const [round, gameNumberStr] = [...gameKeys][0].split("|");
// relevant when there are multiple games in a matchup (e.g. Game #2), const gameNumber = parseInt(gameNumberStr, 10);
// but "Game #1" is redundant when there's only one game. if (gameNumber > 1) {
// Game #2+ indicates a multi-game series — show the game number so
// users can tell which game in the series is upcoming.
event.matchLabel =
round === event.name
? `Game #${gameNumberStr}`
: `${round} Game #${gameNumberStr}`;
} else {
// Single game (game #1 only) — no number needed, just show the round.
event.matchLabel = round === event.name ? null : round;
}
} else if (gameKeys.size > 1) {
// Multiple games across the matchup — use just the round name.
const rounds = new Set([...gameKeys].map((k) => k.split("|")[0])); const rounds = new Set([...gameKeys].map((k) => k.split("|")[0]));
if (rounds.size === 1) { if (rounds.size === 1) {
const round = [...rounds][0]; const round = [...rounds][0];