diff --git a/app/models/__tests__/upcoming-calendar.test.ts b/app/models/__tests__/upcoming-calendar.test.ts index 81ee73f..03997b1 100644 --- a/app/models/__tests__/upcoming-calendar.test.ts +++ b/app/models/__tests__/upcoming-calendar.test.ts @@ -388,6 +388,24 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => { 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 () => { const participants = [makeParticipant("p1", "Verstappen")]; mockDb.query.scoringEvents.findMany.mockResolvedValue([ diff --git a/app/models/scoring-event.ts b/app/models/scoring-event.ts index 18470f5..a3b5456 100644 --- a/app/models/scoring-event.ts +++ b/app/models/scoring-event.ts @@ -528,10 +528,22 @@ export async function getUpcomingEventsForDraftedParticipants( // Build matchLabel from game keys const gameKeys = gameKeysByEvent.get(eventId) ?? new Set(); - if (gameKeys.size >= 1) { - // Only show the round name, not game numbers. Game numbers are only - // relevant when there are multiple games in a matchup (e.g. Game #2), - // but "Game #1" is redundant when there's only one game. + if (gameKeys.size === 1) { + const [round, gameNumberStr] = [...gameKeys][0].split("|"); + const gameNumber = parseInt(gameNumberStr, 10); + 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])); if (rounds.size === 1) { const round = [...rounds][0];