diff --git a/CHANGELOG.md b/CHANGELOG.md index 928f6b1..ffba7a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.13 + +### Fixed + +- Changing a race's qualifying ranking afterwards (best N laps, method) now also re-ranks the qualifiers already run, not only the ones still to run. Heat time and start mode still only reach heats not run yet. + ## 1.89.12 ### Added diff --git a/README.md b/README.md index 1fc2522..8307257 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ After creation the race is managed in four tabs (Race Setup → Manage): - Run it on Race Day. Drivers change when the pack is flat - no driver-change rules. Teams, cars and the length can be changed while it runs (a broken car, a wrong transponder): the laps stay with the team. **Overlay → Team** shows the top 3 with the active driver and the team standings. - **Format:** - qualifying rounds, cars per heat, duration and start mode (mass, position, staggered, flying); - - seeding (best N laps total, average, or consecutive); + - seeding (best N laps total, average, or consecutive). Changing it afterwards, e.g. from best 3 laps to laps and time, also re-ranks the qualifiers already run (results are worked out from the laps); a changed heat time only reaches heats not run yet. Finals already created are not redrawn; - qualifying points table (placement, by field size, 10-9-8...) and tie-break; - finals: legs, counted legs, bump-ups and reserved bump slots; - count-down length, follow-up time and the min/max lap time; diff --git a/README.sv.md b/README.sv.md index 3010374..7668b0e 100644 --- a/README.sv.md +++ b/README.sv.md @@ -176,7 +176,7 @@ Efter det hanteras racet i fyra flikar (Race Setup → Hantera): - Kör det på Race Day. Förarna byter när packet är slut – inga regler för förarbyten. Lag, bilar och längd kan ändras under racet (trasig bil, fel transponder): varven stannar hos laget. **Overlay → Team** visar topp 3 med aktiv förare och lagställningen. - **Format:** - kvalomgångar, bilar per heat, tid och starttyp (mass, position, staggered, flygande); - - seedning (bästa N varv sammanlagt, snitt eller i följd); + - seedning (bästa N varv sammanlagt, snitt eller i följd). Ändras den i efterhand, t.ex. från bästa 3 varv till varv och tid, räknas även körda kval om (resultaten räknas fram från varven); en ändrad heattid gäller bara heat som inte körts. Redan skapade finaler lottas inte om; - poängtabell för kval (placering, efter fältstorlek, 10-9-8...) och tie-break; - finaler: antal finalheat, räknade finalheat, bump-up och reserverade bump-platser; - nedräkningens längd, follow-up-tid och min/max-varvtid; diff --git a/package-lock.json b/package-lock.json index 269c15a..cc3dbfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.12", + "version": "1.89.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.12", + "version": "1.89.13", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index a540bec..b484704 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.12", + "version": "1.89.13", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/event_race_logic.js b/src/event_race_logic.js index 85cf75a..524805f 100644 --- a/src/event_race_logic.js +++ b/src/event_race_logic.js @@ -1150,6 +1150,9 @@ export function buildEventSchedule(event, sessions) { // A changed race format reaches the sessions not run yet: when e.g. "qualifying time" goes // 5 -> 3 min, every ready practice/qualifying session gets 3 min. Only fields whose format // value changed are applied, so a heat edited by hand keeps its own other values. +// How a heat is ranked (best N laps, method) only decides its result, which is worked out from +// the laps each time: a wrong choice fixed afterwards also re-ranks heats already run. +const RANKING_ONLY_KEYS = new Set(["qualSeedLapCount", "qualSeedMethod"]); export function applyFormatToPendingSessions(sessions, before = {}, after = {}) { const fields = { practice: [["qualDurationMin", "durationMin"]], @@ -1158,9 +1161,10 @@ export function applyFormatToPendingSessions(sessions, before = {}, after = {}) }; let changed = 0; sessions.forEach((session) => { - if (session.status !== "ready" || session.startedAt) return; + const pending = session.status === "ready" && !session.startedAt; let touched = false; (fields[session.type] || []).forEach(([configKey, sessionKey]) => { + if (!pending && !RANKING_ONLY_KEYS.has(configKey)) return; if (after[configKey] === undefined || after[configKey] === before[configKey]) return; session[sessionKey] = after[configKey]; touched = true; diff --git a/tests/race_day_fixes.test.js b/tests/race_day_fixes.test.js index 505cee6..e1e9dc4 100644 --- a/tests/race_day_fixes.test.js +++ b/tests/race_day_fixes.test.js @@ -58,3 +58,15 @@ test("the background refresh keeps the objects a form already holds", () => { held.durationMin = 4; assert.equal(next[0].durationMin, 4, "so an edit through the held reference is not lost"); }); + +test("a ranking fixed afterwards (best 3 laps -> laps and time) re-ranks qualifiers already run; their time stays", () => { + const sessions = [ + { id: "q1", type: "qualification", status: "finished", startedAt: 1, durationMin: 5, seedBestLapCount: 3, seedMethod: "consecutive" }, + { id: "q2", type: "qualification", status: "ready", durationMin: 5, seedBestLapCount: 3, seedMethod: "consecutive" }, + ]; + applyFormatToPendingSessions(sessions, { qualSeedLapCount: 3, qualDurationMin: 5 }, { qualSeedLapCount: 0, qualDurationMin: 4 }); + assert.equal(sessions[0].seedBestLapCount, 0, "the finished qualifier follows the new ranking"); + assert.equal(sessions[0].durationMin, 5, "but keeps the time it was run with"); + assert.equal(sessions[1].seedBestLapCount, 0); + assert.equal(sessions[1].durationMin, 4); +});