From f92a93f5213c427bf0ffe574c0809a426072102a Mon Sep 17 00:00:00 2001 From: larssand Date: Tue, 10 Nov 2026 12:59:32 +0100 Subject: [PATCH] feat(day): autopilot says which classes are waiting for finals (1.88.2) --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- src/app.js | 8 +++++++- src/day_schedule_logic.js | 6 ++++-- tests/day_schedule.test.js | 2 ++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea368ea..74bb6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.88.2 + +- Day autopilot: when qualifying is done for a class but its finals are not created yet, the status says "Waiting: check qualifying and press 🏁 Create finals for " instead of "every heat has been run". Finals are still never created automatically. + ## 1.88.1 ### Changed diff --git a/package-lock.json b/package-lock.json index 1741c39..2fac115 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.88.1", + "version": "1.88.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.88.1", + "version": "1.88.2", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index 190fa30..7c530e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.88.1", + "version": "1.88.2", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index dc1fc18..dc28591 100644 --- a/src/app.js +++ b/src/app.js @@ -457,6 +457,7 @@ function setAutopilot(date, on) { } function describeAutopilot(action) { const name = action.row ? `${getDayClassLabel(action.row.session)} ${action.row.session.name}`.trim() : ""; + if (action.reason === "finals") return t("day.auto_finals", { classes: action.classes.join(", ") }); if (action.reason === "until") return t("day.auto_until", { name, time: formatDayClock(action.row.start), min: Math.max(0, Math.ceil((action.launchAt - Date.now()) / 60000)) }); return t(`day.auto_${action.reason}`, { name }); } @@ -466,7 +467,10 @@ function tickAutopilot() { const rows = buildDayRows(autopilotDate); const busy = Boolean(getPrologueSession() || pendingStartSessionId || startsInProgress > 0 || autopilotLaunchingId || state.sessions.some((session) => ["running", "paused"].includes(session.status))); - let action = getAutopilotAction(rows, { day, busy, prologueMs: (session) => (usesCountDown(session) ? getDefaultPrologueSec(session) * 1000 : 0) }); + const finalsPending = [...new Set(state.events + .filter((event) => event.date === autopilotDate && shouldOfferFinals(state, event.id)) + .map((event) => (event.classId ? getClassName(event.classId) : event.name || "")).filter(Boolean))]; + let action = getAutopilotAction(rows, { day, busy, finalsPending, prologueMs: (session) => (usesCountDown(session) ? getDefaultPrologueSec(session) * 1000 : 0) }); if (action.type === "start") { const session = action.row.session; if (!state.decoder?.connected) action = { type: "wait", reason: "decoder", row: action.row }; @@ -3360,6 +3364,7 @@ const TRANSLATIONS = { "day.auto_running": "VĂ€ntar tills heatet pĂ„ banan Ă€r klart", "day.auto_paused": "Dagen Ă€r pausad", "day.auto_done": "Alla heat i schemat Ă€r körda", + "day.auto_finals": "VĂ€ntar: kontrollera kvalet och tryck 🏁 Skapa finaler för {classes}", "day.auto_decoder": "VĂ€ntar: decodern Ă€r inte ansluten ({name} stĂ„r pĂ„ tur)", "day.auto_preflight": "VĂ€ntar: {name} Ă€r inte redo – se kontrollerna", "day.print_title": "Körordning {date}", @@ -5619,6 +5624,7 @@ const TRANSLATIONS = { "day.auto_running": "Waiting for the heat on track to finish", "day.auto_paused": "The day is paused", "day.auto_done": "Every heat in the schedule has been run", + "day.auto_finals": "Waiting: check qualifying and press 🏁 Create finals for {classes}", "day.auto_decoder": "Waiting: the decoder is not connected ({name} is next)", "day.auto_preflight": "Waiting: {name} is not ready – see the checks", "day.print_title": "Running order {date}", diff --git a/src/day_schedule_logic.js b/src/day_schedule_logic.js index 78d3940..dfbbd07 100644 --- a/src/day_schedule_logic.js +++ b/src/day_schedule_logic.js @@ -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 }; } diff --git a/tests/day_schedule.test.js b/tests/day_schedule.test.js index 580c4a9..97500aa 100644 --- a/tests/day_schedule.test.js +++ b/tests/day_schedule.test.js @@ -57,6 +57,8 @@ test("the autopilot waits for the planned time minus the count-down, never while assert.equal(getAutopilotAction(rows, { day: {}, now: start, busy: true, prologueMs }).reason, "running"); assert.equal(getAutopilotAction(rows, { day: { pausedAt: start }, now: start, prologueMs }).reason, "paused"); assert.equal(getAutopilotAction([], { day: {}, now: start }).reason, "done"); + assert.deepEqual(getAutopilotAction([], { day: {}, now: start, finalsPending: ["Buggy 4WD", "Buggy 2WD"] }), { type: "wait", reason: "finals", classes: ["Buggy 4WD", "Buggy 2WD"] }); + assert.equal(getAutopilotAction(rows, { day: {}, now: start - 120000, prologueMs, finalsPending: ["Buggy 4WD"] }).type, "start", "a heat still to run goes first"); }); test("race days are stored one per date, and the board shows today or the next day still to race", () => {