From 6d6508d50378c8b83704288dae7e82a1a282dccf Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Mar 2026 20:41:19 +0000 Subject: [PATCH] Show game number for Game #2+ in series, hide Game #1 for single-game matchups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../__tests__/upcoming-calendar.test.ts | 18 +++++++++++++++++ app/models/scoring-event.ts | 20 +++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) 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];