Cache isSeries per entry to avoid re-deriving it in the finalization loop
https://claude.ai/code/session_01CRrqu43FKHshpJt1NyrDdX
This commit is contained in:
parent
01b012e09c
commit
aca6f3d327
1 changed files with 4 additions and 4 deletions
|
|
@ -508,6 +508,7 @@ export async function getUpcomingEventsForDraftedParticipants(
|
||||||
const participantsByEntry = new Map<string, Map<string, { id: string; name: string }>>();
|
const participantsByEntry = new Map<string, Map<string, { id: string; name: string }>>();
|
||||||
const gameKeysByEntry = new Map<string, Set<string>>();
|
const gameKeysByEntry = new Map<string, Set<string>>();
|
||||||
const earliestTimeByEntry = new Map<string, Date>();
|
const earliestTimeByEntry = new Map<string, Date>();
|
||||||
|
const isSeriesByEntry = new Map<string, boolean>();
|
||||||
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const isSeries = (maxGameNumberByEvent.get(row.id) ?? 1) > 1;
|
const isSeries = (maxGameNumberByEvent.get(row.id) ?? 1) > 1;
|
||||||
|
|
@ -527,6 +528,7 @@ export async function getUpcomingEventsForDraftedParticipants(
|
||||||
});
|
});
|
||||||
participantsByEntry.set(entryKey, new Map());
|
participantsByEntry.set(entryKey, new Map());
|
||||||
gameKeysByEntry.set(entryKey, new Set());
|
gameKeysByEntry.set(entryKey, new Set());
|
||||||
|
isSeriesByEntry.set(entryKey, isSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pMap = participantsByEntry.get(entryKey);
|
const pMap = participantsByEntry.get(entryKey);
|
||||||
|
|
@ -559,19 +561,17 @@ export async function getUpcomingEventsForDraftedParticipants(
|
||||||
const earliest = earliestTimeByEntry.get(entryKey);
|
const earliest = earliestTimeByEntry.get(entryKey);
|
||||||
event.earliestGameTime = earliest ? earliest.toISOString() : null;
|
event.earliestGameTime = earliest ? earliest.toISOString() : null;
|
||||||
|
|
||||||
const eventId = entryKey.split("|")[0];
|
const isSeries = isSeriesByEntry.get(entryKey) ?? false;
|
||||||
const isSeries = (maxGameNumberByEvent.get(eventId) ?? 1) > 1;
|
|
||||||
const gameKeys = gameKeysByEntry.get(entryKey) ?? new Set<string>();
|
const gameKeys = gameKeysByEntry.get(entryKey) ?? new Set<string>();
|
||||||
|
|
||||||
if (isSeries) {
|
if (isSeries) {
|
||||||
// Each entry is for a specific game in a series — always show the game number.
|
|
||||||
if (gameKeys.size >= 1) {
|
if (gameKeys.size >= 1) {
|
||||||
const [round, gameNumberStr] = [...gameKeys][0].split("|");
|
const [round, gameNumberStr] = [...gameKeys][0].split("|");
|
||||||
event.matchLabel =
|
event.matchLabel =
|
||||||
round === event.name ? `Game #${gameNumberStr}` : `${round} Game #${gameNumberStr}`;
|
round === event.name ? `Game #${gameNumberStr}` : `${round} Game #${gameNumberStr}`;
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if (gameKeys.size === 1) {
|
||||||
const [round] = [...gameKeys][0].split("|");
|
const [round] = [...gameKeys][0].split("|");
|
||||||
event.matchLabel = round === event.name ? null : round;
|
event.matchLabel = round === event.name ? null : round;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue