From aca6f3d327eeea798b595d41cfff8b29da06d165 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Mar 2026 23:36:22 +0000 Subject: [PATCH] Cache isSeries per entry to avoid re-deriving it in the finalization loop https://claude.ai/code/session_01CRrqu43FKHshpJt1NyrDdX --- app/models/scoring-event.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/scoring-event.ts b/app/models/scoring-event.ts index c59ad96..6120309 100644 --- a/app/models/scoring-event.ts +++ b/app/models/scoring-event.ts @@ -508,6 +508,7 @@ export async function getUpcomingEventsForDraftedParticipants( const participantsByEntry = new Map>(); const gameKeysByEntry = new Map>(); const earliestTimeByEntry = new Map(); + const isSeriesByEntry = new Map(); for (const row of rows) { const isSeries = (maxGameNumberByEvent.get(row.id) ?? 1) > 1; @@ -527,6 +528,7 @@ export async function getUpcomingEventsForDraftedParticipants( }); participantsByEntry.set(entryKey, new Map()); gameKeysByEntry.set(entryKey, new Set()); + isSeriesByEntry.set(entryKey, isSeries); } const pMap = participantsByEntry.get(entryKey); @@ -559,19 +561,17 @@ export async function getUpcomingEventsForDraftedParticipants( const earliest = earliestTimeByEntry.get(entryKey); event.earliestGameTime = earliest ? earliest.toISOString() : null; - const eventId = entryKey.split("|")[0]; - const isSeries = (maxGameNumberByEvent.get(eventId) ?? 1) > 1; + const isSeries = isSeriesByEntry.get(entryKey) ?? false; const gameKeys = gameKeysByEntry.get(entryKey) ?? new Set(); if (isSeries) { - // Each entry is for a specific game in a series — always show the game number. if (gameKeys.size >= 1) { const [round, gameNumberStr] = [...gameKeys][0].split("|"); event.matchLabel = round === event.name ? `Game #${gameNumberStr}` : `${round} Game #${gameNumberStr}`; } } else { - // Single-game matchup — show the round name, no game number. + // Single-game: omit the game number, just show the round name. if (gameKeys.size === 1) { const [round] = [...gameKeys][0].split("|"); event.matchLabel = round === event.name ? null : round;