feat(day): autopilot says which classes are waiting for finals (1.89.0)
This commit is contained in:
1 parent
3e78db9156
commit
d044fee171
6 files changed
+20
-6
No files matched your search
@@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.0
|
||||
|
||||
- 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 <classes>" instead of "every heat has been run". Finals are still never created automatically.
|
||||
|
||||
## 1.88.1
|
||||
|
||||
### Changed
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.88.1",
|
||||
"version": "1.89.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.88.1",
|
||||
"version": "1.89.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.88.1",
|
||||
"version": "1.89.0",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
+7
-1
@@ -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}",
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in new issue
Block a user