Code review fixes: earliestGameTime fallback, isNaN guard, and missing index
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m58s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m18s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped

- getUpcomingScoringEvents: fall back to eventStartsAt.toISOString() when no
  game-level scheduledAt exists, matching the same pattern already used in
  getUpcomingEventsForDraftedParticipants — prevents F1/golf events from
  showing a date with no time in SportSeasonCard and similar consumers
- EventSchedule: replace bare toLocaleTimeString call with an isNaN-guarded
  block so a malformed timestamp renders nothing instead of "Invalid Date"
- database/schema.ts: add index on tournament_groups(scoring_event_id) to
  support the inArray filter added in the previous commit
  (run npm run db:generate && npm run db:migrate to apply)

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 17:47:24 +00:00
parent 9a04e25c20
commit fa98d514f2
No known key found for this signature in database
3 changed files with 13 additions and 5 deletions

View file

@ -113,9 +113,13 @@ export function EventSchedule({ upcomingEvents, recentEvents, leagueId, sportsSe
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-0.5">
<Calendar className="h-3 w-3" />
<span>{getDisplayDate(event)}</span>
{isMounted && (event.earliestGameTime ?? event.eventStartsAt) && (
<span>· {new Date(event.earliestGameTime ?? (event.eventStartsAt as string)).toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}</span>
)}
{isMounted && (() => {
const ts = event.earliestGameTime ?? (event.eventStartsAt as string | null | undefined);
if (!ts) return null;
const d = new Date(ts);
if (isNaN(d.getTime())) return null;
return <span>· {d.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}</span>;
})()}
</p>
</div>
{event.eventType === "schedule_event" ? (

View file

@ -379,7 +379,9 @@ export async function getUpcomingScoringEvents(
.slice(0, limit)
.map((e) => ({
...e,
earliestGameTime: earliestGameById.get(e.id)?.toISOString() ?? null,
earliestGameTime: earliestGameById.get(e.id)?.toISOString()
?? e.eventStartsAt?.toISOString()
?? null,
}));
}

View file

@ -886,7 +886,9 @@ export const tournamentGroups = pgTable("tournament_groups", {
.references(() => scoringEvents.id, { onDelete: "cascade" }),
groupName: varchar("group_name", { length: 10 }).notNull(), // "A" through "L"
createdAt: timestamp("created_at").defaultNow().notNull(),
});
}, (t) => [
index("tournament_groups_scoring_event_id_idx").on(t.scoringEventId),
]);
export const tournamentGroupMembers = pgTable("tournament_group_members", {
id: uuid("id").primaryKey().defaultRandom(),