From 7241963a061b9b63b98b35505341d5b7743911be Mon Sep 17 00:00:00 2001 From: CoolGame8 Date: Wed, 28 Jan 2026 10:13:37 +0200 Subject: [PATCH 1/2] fix? --- .../reports/field-schedule/graphql/query.ts | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts b/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts index 5e2573761..75a56d13b 100644 --- a/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts +++ b/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts @@ -123,23 +123,53 @@ export function parseFieldScheduleData(data: QueryData) { return dayjs(firstMatchA.scheduledTime).diff(dayjs(firstMatchB.scheduledTime)); }); - // For each round, slice the rows array to get only events that belong to that round + // For each round, create rows with only matches and events that belong to that round const roundRowsMap = sortedRoundKeys.reduce( (result: { [key: string]: typeof rows }, roundKey, roundIndex) => { - const isFirstRound = roundIndex === 0; - const isLastRound = roundIndex === sortedRoundKeys.length - 1; + const currentRoundMatches = roundMatches[roundKey]; + const roundRows: typeof rows = []; + + // Get time boundaries for this round + const lastMatchTime = dayjs(currentRoundMatches[currentRoundMatches.length - 1].scheduledTime); + + // Get the start boundary (before first match of this round) + const startBoundary = roundIndex > 0 + ? dayjs(roundMatches[sortedRoundKeys[roundIndex - 1]][roundMatches[sortedRoundKeys[roundIndex - 1]].length - 1].scheduledTime) + : dayjs(0); + + // Get the end boundary (before first match of next round, or infinity for last round) + const endBoundary = roundIndex < sortedRoundKeys.length - 1 + ? dayjs(roundMatches[sortedRoundKeys[roundIndex + 1]][0].scheduledTime) + : dayjs('9999-12-31'); + + // Add matches and events for this round in chronological order + currentRoundMatches.forEach((match, matchIndex) => { + const matchTime = dayjs(match.scheduledTime); + const previousMatchTime = matchIndex > 0 + ? dayjs(currentRoundMatches[matchIndex - 1].scheduledTime) + : startBoundary; + + // Add agenda events that fall between previous match and this match + agenda.forEach(event => { + const eventStart = dayjs(event.startTime); + if (eventStart.isAfter(previousMatchTime) && eventStart.isBefore(matchTime)) { + roundRows.push({ type: 'event', data: event }); + } + }); - // Find start index (0 for first round, first match of current round for others) - const startIndex = isFirstRound - ? 0 - : matchIdToRowIndex.get(roundMatches[roundKey][0].id); + // Add the match + roundRows.push({ type: 'match', data: match }); + }); - // Find end index (last row for last round, first match of next round for others) - const endIndex = isLastRound - ? rows.length - : matchIdToRowIndex.get(roundMatches[sortedRoundKeys[roundIndex + 1]][0].id); + // Add events after the last match of this round but before the next round + agenda.forEach(event => { + const eventStart = dayjs(event.startTime); + if (eventStart.isAfter(lastMatchTime) && eventStart.isBefore(endBoundary)) { + roundRows.push({ type: 'event', data: event }); + } + }); - result[roundKey] = rows.slice(startIndex, endIndex); + result[roundKey] = roundRows; return result; }, From a220584cc15ef364b38e33488c61ea438fbb1f3c Mon Sep 17 00:00:00 2001 From: CoolGame8 Date: Wed, 28 Jan 2026 10:15:00 +0200 Subject: [PATCH 2/2] dam --- .../(dashboard)/reports/field-schedule/graphql/query.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts b/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts index 75a56d13b..b813b9891 100644 --- a/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts +++ b/apps/frontend/src/app/[locale]/lems/(volunteer)/(dashboard)/reports/field-schedule/graphql/query.ts @@ -69,6 +69,11 @@ export function parseFieldScheduleData(data: QueryData) { // Sort matches by number const sortedMatches = [...matches].sort((a, b) => a.number - b.number); + // If no matches, return empty data + if (sortedMatches.length === 0) { + return { teams: [], tables: [], roundMatches: {}, roundRowsMap: {} }; + } + // Create rows combining matches and agenda events, sorted by time const rows: Array< { type: 'match'; data: RobotGameMatch } | { type: 'event'; data: AgendaEvent }