feat(day): autopilot says which classes are waiting for finals (1.88.2)
This commit is contained in:
1 parent
3e78db9156
commit
f92a93f521
6 files changed
+20
-6
No files matched your search
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user