diff --git a/CHANGELOG.md b/CHANGELOG.md index a7dcb5e..ade4f10 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.70.3 + +### Fixed +- Open practice: "Reset – new practice day" restarts the clock from 0:00; it kept counting from the first start. + ## 1.70.2 ### Fixed diff --git a/package-lock.json b/package-lock.json index 7e59d07..f6d5cb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.70.2", + "version": "1.70.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.70.2", + "version": "1.70.3", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index a4615dc..6dd7cc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.70.2", + "version": "1.70.3", "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 9fa5fa2..cefc857 100644 --- a/src/app.js +++ b/src/app.js @@ -608,6 +608,10 @@ function resetSessionData(session) { // the server's live-results protection when the reset came right after the last lap. ensureSessionResult(session.id); Object.assign(session, { status: "ready", startedAt: null, endedAt: null, finishedByTimer: false, pausedAt: null, totalPausedMs: 0, followUpPausedMs: 0, audioAnnouncements: [] }); + } else if (["running", "paused"].includes(session.status)) { + // A practice that keeps running: its clock starts again from zero (a paused one stays paused at 0:00). + const now = Date.now(); + Object.assign(session, { startedAt: now, pausedAt: session.status === "paused" ? now : null, totalPausedMs: 0, followUpPausedMs: 0, audioAnnouncements: [] }); } lastFinishAnnouncementSessionId = null; delete lastOverlayLeaderKeyBySession[session.id]; diff --git a/tests/browser_practice_reset.js b/tests/browser_practice_reset.js index 66b26af..8ecc192 100644 --- a/tests/browser_practice_reset.js +++ b/tests/browser_practice_reset.js @@ -50,9 +50,11 @@ export async function runPracticeResetSmoke({ evaluate, navigate, savedState, wa await waitFor(async () => ((await savedState()).resultsBySession?.[practice.id]?.passings || []).length === 0, "timing data cleared"); assert.deepEqual((await driverLaps()).sort(), [19000, 19500, 20000], "laps kept right after the reset"); assert.equal((await savedState()).sessions.find((session) => session.id === practice.id).status, "running", "the practice keeps running"); + assert.ok((await savedState()).sessions.find((session) => session.id === practice.id).startedAt > startedAt + 500000, "the practice clock starts again from zero"); await waitFor(async () => evaluate('document.getElementById("connectionBadge")?.classList.contains("badge-online")'), "decoder connected"); - decoder.sendPassing("8220001"); + // The clock restarted at the reset, so the first lap is measured from there: a car crossing 20 s later. + decoder.sendPassing("8220001", Date.now() + 20000); await waitFor(async () => ((await savedState()).resultsBySession?.[practice.id]?.passings || []).length >= 1, "a new lap after the reset"); await waitFor(async () => (await driverLaps()).length === 4, "the new lap joins the training stats"); assert.deepEqual((await driverLaps()).slice(0, 3), [20000, 19500, 19000], "the laps from before the reset are still there");