Also fetch group stage match times for sport-season event schedule

The previous fix only queried playoffMatchGames.scheduledAt for bracket
events. FIFA World Cup group stage matches live in groupStageMatches
(linked via tournamentGroups), not playoffMatchGames. Now
getUpcomingScoringEvents fetches both tables in parallel and uses
the earliest scheduledAt from either source as earliestGameTime,
matching what UpcomingCalendarPanel already shows on the Upcoming Events page.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KiVGo8gSBXe3WuRniVNKsd
This commit is contained in:
Claude 2026-06-17 16:57:40 +00:00
parent 363413cd38
commit 9a04e25c20
No known key found for this signature in database

View file

@ -310,10 +310,13 @@ export async function getUpcomingScoringEvents(
if (events.length === 0) return [];
// Find earliest upcoming game time per event from bracket match games.
// Find earliest upcoming game time per event from both bracket match games
// and group stage matches (FIFA World Cup style).
const eventIds = events.map((e) => e.id);
const now = new Date();
const gameTimeRows = await db
const [gameTimeRows, groupStageTimeRows] = await Promise.all([
db
.select({
eventId: schema.scoringEvents.id,
scheduledAt: schema.playoffMatchGames.scheduledAt,
@ -333,10 +336,28 @@ export async function getUpcomingScoringEvents(
isNotNull(schema.playoffMatchGames.scheduledAt),
gte(schema.playoffMatchGames.scheduledAt, now)
)
);
),
db
.select({
eventId: schema.tournamentGroups.scoringEventId,
scheduledAt: schema.groupStageMatches.scheduledAt,
})
.from(schema.groupStageMatches)
.innerJoin(
schema.tournamentGroups,
eq(schema.groupStageMatches.tournamentGroupId, schema.tournamentGroups.id)
)
.where(
and(
inArray(schema.tournamentGroups.scoringEventId, eventIds),
isNotNull(schema.groupStageMatches.scheduledAt),
gte(schema.groupStageMatches.scheduledAt, now)
)
),
]);
const earliestGameById = new Map<string, Date>();
for (const row of gameTimeRows) {
for (const row of [...gameTimeRows, ...groupStageTimeRows]) {
if (!row.scheduledAt) continue;
const prev = earliestGameById.get(row.eventId);
if (!prev || row.scheduledAt < prev) {