diff --git a/CHANGELOG.md b/CHANGELOG.md index 32cbb67..d341493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.45 - 2026-11-16 + +- Dashboard: Schedule drift only counts today's timed heats. Open Practice and free practice no longer count, so an open practice left running, or last weekend's race, no longer shows as hours behind schedule. +- Race Setup wizard, step 3: the practice box no longer says "not used for seeding" (that is free practice). It now explains that these are timed practice heats for the entered drivers that can seed qualifying, and the count field says how many rounds are created. + ## 1.89.44 - 2026-11-16 - Guide and README: the local Piper voice is marked as recommended, and the docs now say to press Pre-generate phrases and driver names again after adding drivers or changing a pronunciation name, voice or speed (existing lines are skipped). A name that is not pre-generated is made the first time it is said, with the browser voice as a one-off fallback if that is slow. diff --git a/package-lock.json b/package-lock.json index 62971cb..20aa544 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.44", + "version": "1.89.45", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.44", + "version": "1.89.45", "hasInstallScript": true, "license": "AGPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 2286856..0b5eb08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.44", + "version": "1.89.45", "private": true, "license": "AGPL-3.0-or-later", "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", diff --git a/src/app.js b/src/app.js index 6597df4..f72ca7b 100644 --- a/src/app.js +++ b/src/app.js @@ -2169,6 +2169,8 @@ const TRANSLATIONS = { "events.wizard_create": "Skapa race", "events.wizard_use_practice": "Skapa practice-sessioner", "events.wizard_practice_sessions": "Antal practice-sessioner", + "events.wizard_practice_hint": "Tidtagna practice-heat i racet med de anmälda förarna (masstart, samma längd som kvalet). Resultatet kan seeda kvalet: Hantera → Skapa kval från practice. Inte samma sak som Open Practice / fri träning.", + "events.wizard_practice_count_hint": "Hur många practice-omgångar som skapas. Gäller bara om rutan till vänster är ikryssad.", "events.wizard_use_qualifying": "Skapa kvalomgångar", "events.wizard_qualifying_rounds": "Antal kvalomgångar", "events.wizard_use_team_race": "Skapa endurance / Team Race-session", @@ -4592,6 +4594,8 @@ const TRANSLATIONS = { "events.wizard_create": "Create race", "events.wizard_use_practice": "Create practice sessions", "events.wizard_practice_sessions": "Practice session count", + "events.wizard_practice_hint": "Timed practice heats in the race with the entered drivers (mass start, same length as qualifying). The result can seed qualifying: Manage → Generate qualifying from practice. Not the same as Open Practice / free practice.", + "events.wizard_practice_count_hint": "How many practice rounds are created. Only used when the box on the left is ticked.", "events.wizard_use_qualifying": "Create qualifying rounds", "events.wizard_qualifying_rounds": "Qualifying rounds", "events.wizard_use_team_race": "Create endurance / Team Race session", diff --git a/src/core_views.js b/src/core_views.js index 8e70cf3..738fade 100644 --- a/src/core_views.js +++ b/src/core_views.js @@ -25,14 +25,21 @@ import { isPracticeSessionType } from "./track_layouts_logic.js"; import { renderTrackLayoutBar, bindTrackLayoutBar } from "./track_layout_bar.js"; import { openHouseOfRcDriverImport, lookupHouseOfRcTransponders } from "./houseofrc_view.js"; -function getScheduleDriftSummary(state) { - const scheduledSessions = state.sessions - .filter((session) => Number(session.startedAt || 0) > 0) +// Open/free practice has no planned length, so it never counts: an open practice left running +// would otherwise grow the drift for as long as the computer is on. +const UNSCHEDULED_SESSION_TYPES = new Set(["open_practice", "free_practice"]); + +// Today's timed sessions only (planned length vs. how long they actually took). Earlier days +// don't count, so last weekend's race doesn't show as hours behind. +export function getScheduleDriftSummary(state, nowTs = Date.now()) { + const dayStart = new Date(nowTs); + dayStart.setHours(0, 0, 0, 0); + const scheduledSessions = (state.sessions || []) + .filter((session) => Number(session.startedAt || 0) >= dayStart.getTime() && !UNSCHEDULED_SESSION_TYPES.has(session.type)) .sort((left, right) => Number(left.startedAt || 0) - Number(right.startedAt || 0)); if (!scheduledSessions.length) { return null; } - const nowTs = Date.now(); const plannedMs = scheduledSessions.reduce( (sum, session) => sum + Math.max(1, Number(session.durationMin || 0) || 0) * 60000 + Math.max(0, Number(session.followUpSec || 0) || 0) * 1000, 0 diff --git a/src/race_setup_ui.js b/src/race_setup_ui.js index 4ccc03a..8947fba 100644 --- a/src/race_setup_ui.js +++ b/src/race_setup_ui.js @@ -140,12 +140,12 @@ export function renderRaceWizardContent(draft, classOptions, wizardDrivers, pres
${!isEndurance ? ` diff --git a/tests/run.js b/tests/run.js index ab61840..3074cf2 100644 --- a/tests/run.js +++ b/tests/run.js @@ -38,6 +38,7 @@ import "./public_training_profile.test.js"; import "./race_timing_logic.test.js"; import "./track_layouts_logic.test.js"; import "./race_day_logic.test.js"; +import "./schedule_drift.test.js"; import "./race_day_export.test.js"; import "./backup_service.test.js"; import "./judging_logic.test.js"; diff --git a/tests/schedule_drift.test.js b/tests/schedule_drift.test.js new file mode 100644 index 0000000..60354dc --- /dev/null +++ b/tests/schedule_drift.test.js @@ -0,0 +1,25 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { getScheduleDriftSummary } from "../src/core_views.js"; + +const now = new Date(2026, 10, 16, 21, 0, 0).getTime(); +const min = 60000; + +test("schedule drift: nothing started today shows no drift", () => { + const lastWeek = now - 3 * 24 * 60 * min; + const state = { sessions: [{ type: "qualification", durationMin: 5, startedAt: lastWeek, endedAt: lastWeek + 6 * min, status: "finished" }] }; + assert.equal(getScheduleDriftSummary(state, now), null); +}); + +test("schedule drift: a running open practice never counts", () => { + const state = { sessions: [{ type: "open_practice", durationMin: 0, startedAt: now - 130 * min, status: "running" }] }; + assert.equal(getScheduleDriftSummary(state, now), null); +}); + +test("schedule drift: today's timed heats are compared with their planned length", () => { + const state = { sessions: [ + { type: "qualification", durationMin: 5, startedAt: now - 60 * min, endedAt: now - 53 * min, status: "finished" }, + { type: "free_practice", durationMin: 0, startedAt: now - 120 * min, endedAt: now - 70 * min, status: "finished" }, + ] }; + assert.deepEqual(getScheduleDriftSummary(state, now), { plannedMs: 5 * min, actualMs: 7 * min, driftMs: 2 * min }); +});