Code review fixes: earliestGameTime fallback, isNaN guard, and missing index
- 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:
parent
9a04e25c20
commit
fa98d514f2
3 changed files with 13 additions and 5 deletions
|
|
@ -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">
|
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-0.5">
|
||||||
<Calendar className="h-3 w-3" />
|
<Calendar className="h-3 w-3" />
|
||||||
<span>{getDisplayDate(event)}</span>
|
<span>{getDisplayDate(event)}</span>
|
||||||
{isMounted && (event.earliestGameTime ?? event.eventStartsAt) && (
|
{isMounted && (() => {
|
||||||
<span>· {new Date(event.earliestGameTime ?? (event.eventStartsAt as string)).toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}</span>
|
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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{event.eventType === "schedule_event" ? (
|
{event.eventType === "schedule_event" ? (
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,9 @@ export async function getUpcomingScoringEvents(
|
||||||
.slice(0, limit)
|
.slice(0, limit)
|
||||||
.map((e) => ({
|
.map((e) => ({
|
||||||
...e,
|
...e,
|
||||||
earliestGameTime: earliestGameById.get(e.id)?.toISOString() ?? null,
|
earliestGameTime: earliestGameById.get(e.id)?.toISOString()
|
||||||
|
?? e.eventStartsAt?.toISOString()
|
||||||
|
?? null,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -886,7 +886,9 @@ export const tournamentGroups = pgTable("tournament_groups", {
|
||||||
.references(() => scoringEvents.id, { onDelete: "cascade" }),
|
.references(() => scoringEvents.id, { onDelete: "cascade" }),
|
||||||
groupName: varchar("group_name", { length: 10 }).notNull(), // "A" through "L"
|
groupName: varchar("group_name", { length: 10 }).notNull(), // "A" through "L"
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
});
|
}, (t) => [
|
||||||
|
index("tournament_groups_scoring_event_id_idx").on(t.scoringEventId),
|
||||||
|
]);
|
||||||
|
|
||||||
export const tournamentGroupMembers = pgTable("tournament_group_members", {
|
export const tournamentGroupMembers = pgTable("tournament_group_members", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue