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:
parent
8c5389909d
commit
6f51ad8c78
2 changed files with 9 additions and 15 deletions
|
|
@ -350,7 +350,7 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
|
|||
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 = [{
|
||||
id: "e1", name: "PDC World Championship", eventDate: "2025-04-09",
|
||||
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
|
||||
|
|
@ -365,12 +365,12 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
|
|||
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
|
||||
// → show "Game #1" rather than the redundant "Knockout Stage Game #1"
|
||||
// → show null rather than redundant label
|
||||
const rows = [{
|
||||
id: "e1", name: "Knockout Stage", eventDate: null,
|
||||
eventType: "playoff_game", sportsSeasonId: SPORTS_SEASON_ID,
|
||||
|
|
@ -385,7 +385,7 @@ describe("getUpcomingEventsForDraftedParticipants — bracket sports", () => {
|
|||
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 () => {
|
||||
|
|
|
|||
|
|
@ -528,16 +528,10 @@ export async function getUpcomingEventsForDraftedParticipants(
|
|||
|
||||
// Build matchLabel from game keys
|
||||
const gameKeys = gameKeysByEvent.get(eventId) ?? new Set<string>();
|
||||
if (gameKeys.size === 1) {
|
||||
const [round, gameNumberStr] = [...gameKeys][0].split("|");
|
||||
// When round name duplicates the event name, omit the round to avoid
|
||||
// "Knockout Stage — Knockout Stage Game #1"; just show "Game #1" instead.
|
||||
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
|
||||
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.
|
||||
const rounds = new Set([...gameKeys].map((k) => k.split("|")[0]));
|
||||
if (rounds.size === 1) {
|
||||
const round = [...rounds][0];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue