Don't show Game #1 label for single-game matchups in calendar

When a matchup has only one game, showing "Game #1" is redundant and
unhelpful. Only show game numbers when there are multiple games in a
matchup (gameKeys.size > 1). For single-game matchups, show just the
round name (or null if it matches the event name).

Closes #198

https://claude.ai/code/session_01CRrqu43FKHshpJt1NyrDdX
This commit is contained in:
Claude 2026-03-22 20:38:23 +00:00
parent 8c5389909d
commit 6f51ad8c78
No known key found for this signature in database
2 changed files with 9 additions and 15 deletions

View file

@ -350,7 +350,7 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
expect(result[0].earliestGameTime).toBe(gameTime1.toISOString()); expect(result[0].earliestGameTime).toBe(gameTime1.toISOString());
}); });
it("sets matchLabel to round+game when single game key (non-redundant)", async () => { it("sets matchLabel to round name only (no game number) for single-game matchup", async () => {
const rows = [{ const rows = [{
id: "e1", name: "PDC World Championship", eventDate: "2025-04-09", id: "e1", name: "PDC World Championship", eventDate: "2025-04-09",
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID, eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
@ -365,12 +365,12 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
DATE_FROM, DATE_TO DATE_FROM, DATE_TO
); );
expect(result[0].matchLabel).toBe("Semifinals Game #1"); expect(result[0].matchLabel).toBe("Semifinals");
}); });
it("omits redundant round prefix when round name matches event name", async () => { it("sets matchLabel to null when round name matches event name (single game)", async () => {
// e.g. event named "Knockout Stage", round also "Knockout Stage", single game // e.g. event named "Knockout Stage", round also "Knockout Stage", single game
// → show "Game #1" rather than the redundant "Knockout Stage Game #1" // → show null rather than redundant label
const rows = [{ const rows = [{
id: "e1", name: "Knockout Stage", eventDate: null, id: "e1", name: "Knockout Stage", eventDate: null,
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID, eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
@ -385,7 +385,7 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
DATE_FROM, DATE_TO DATE_FROM, DATE_TO
); );
expect(result[0].matchLabel).toBe("Game #1"); expect(result[0].matchLabel).toBeNull();
}); });
it("all-compete events have null earliestGameTime and matchLabel", async () => { it("all-compete events have null earliestGameTime and matchLabel", async () => {

View file

@ -528,16 +528,10 @@ 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) {
const [round, gameNumberStr] = [...gameKeys][0].split("|"); // Only show the round name, not game numbers. Game numbers are only
// When round name duplicates the event name, omit the round to avoid // relevant when there are multiple games in a matchup (e.g. Game #2),
// "Knockout Stage — Knockout Stage Game #1"; just show "Game #1" instead. // but "Game #1" is redundant when there's only one game.
event.matchLabel =
round === event.name
? `Game #${gameNumberStr}`
: `${round} Game #${gameNumberStr}`;
} else if (gameKeys.size > 1) {
// Multiple games — use just the round if it differs from the event 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];