feat(day): autopilot says which classes are waiting for finals (1.88.2)

This commit is contained in:
larssand committed 2026-11-10 14:43:43 +01:00
1 parent 3e78db9156
commit f92a93f521
6 files changed
+20 -6

No files matched your search

+4 -2
View File
@@ -124,11 +124,13 @@ export function buildDaySchedule(ordered, day, now = Date.now()) {
// What the autopilot does now: { type: "start", row, launchAt } or { type: "wait", reason, row?, launchAt? }.
// prologueMs(session) = how long before the planned start its count-down begins.
export function getAutopilotAction(rows, { day, now = Date.now(), busy = false, prologueMs = () => 0 }) {
// finalsPending = the classes whose qualifying is done but whose finals are not created yet:
// the autopilot never creates finals (qualifying may need corrections first), it waits for them.
export function getAutopilotAction(rows, { day, now = Date.now(), busy = false, prologueMs = () => 0, finalsPending = [] }) {
if (day?.pausedAt) return { type: "wait", reason: "paused" };
if (busy || rows.some((row) => row.state === "live")) return { type: "wait", reason: "running" };
const row = rows.find((item) => item.state === "upcoming");
if (!row) return { type: "wait", reason: "done" };
if (!row) return finalsPending.length ? { type: "wait", reason: "finals", classes: finalsPending } : { type: "wait", reason: "done" };
const launchAt = row.start - Math.max(0, Number(prologueMs(row.session) || 0));
return now >= launchAt ? { type: "start", row, launchAt } : { type: "wait", reason: "until", row, launchAt };
}