fix(race): a changed qualifying ranking also re-ranks qualifiers already run (1.89.13)

This commit is contained in:
larssand committed 2026-11-12 21:52:11 +01:00
1 parent 4a1460b480
commit 1b968bc275
7 files changed
+28 -6

No files matched your search

+6
View File
@@ -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
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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",
+1 -1
View File
@@ -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": {
+5 -1
View File
@@ -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;
+12
View File
@@ -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);
});