feat(day): one start time - Race setup's start time and gap are Race Day's, with Race Day's times shown (1.89.17)
This commit is contained in:
1 parent
cb29c5471b
commit
f8080ffaeb
11 files changed
+122
-17
No files matched your search
@@ -55,6 +55,31 @@ export function getRaceDay(raceDays, date) {
|
||||
return (raceDays || []).find((day) => day.date === date) || normalizeRaceDay({ date });
|
||||
}
|
||||
|
||||
// Race Day's first start is the only start time. A race that got one in Race setup before the
|
||||
// two were joined lends it to its day while the day has none of its own.
|
||||
const localDate = (ms) => { const d = new Date(ms); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; };
|
||||
export function withRaceSetupStart(day, events = []) {
|
||||
if (!day || Number(day.startAt) > 0) return day;
|
||||
const legacy = (events || [])
|
||||
.filter((event) => event.date === day.date)
|
||||
.map((event) => Number(event.raceConfig?.scheduleStartAt || 0))
|
||||
.filter((ms) => ms > 0 && localDate(ms) === day.date)
|
||||
.sort((a, b) => a - b)[0];
|
||||
return legacy ? { ...day, startAt: legacy } : day;
|
||||
}
|
||||
|
||||
// One race's part of the day schedule, in the shape Race setup and the printed start lists use.
|
||||
export function eventScheduleFromDayRows(rows, eventId) {
|
||||
return (rows || []).filter((row) => row.session.eventId === eventId).map((row) => ({
|
||||
sessionId: row.session.id,
|
||||
plannedStart: row.start,
|
||||
plannedEnd: row.end,
|
||||
actualStart: Number(row.session.startedAt || 0) || null,
|
||||
actualEnd: row.state === "done" ? Number(row.session.endedAt || 0) || null : null,
|
||||
delayed: row.delayed,
|
||||
}));
|
||||
}
|
||||
|
||||
// Stores a changed plan for its date; returns the new list.
|
||||
export function upsertRaceDay(raceDays, day) {
|
||||
const next = normalizeRaceDay(day);
|
||||
|
||||
Reference in new issue
Block a user