fix(timing): shared transponder goes to the driver in the heat; confirm before remaking run finals (1.89.35)

This commit is contained in:
larssand committed 2026-11-15 15:02:26 +01:00
1 parent 1348b9b57e
commit 01abe5b7ae
7 files changed
+68 -6

No files matched your search

+7
View File
@@ -8,6 +8,13 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.89.35
### Fixed
- One transponder on two drivers (the same person in 2WD and 4WD): the lap now goes to the driver who is in the running heat (then the race's entry list, its class, a club driver before a guest). Before, the first match in the club list took it, and since that driver wasn't in the heat the lap was thrown away as an unknown transponder.
- Generate finals / Clear generated finals in Manage race now ask first when finals have already run, naming them - making the finals again deletes their laps and results.
## 1.89.34
- **Whole race days as presets, federation style:** new race format presets **EFRA 1/10 Off-road**, **EFRA 1/10 Touring / On-road**, **EFRA/SBF 1/8 Nitro** (bump-up, long final), **ROAR** (timed qualifying, bump-up, single A main), **Quick club day**, **Rookie / Junior** and **Points race without finals**; **IFMAR** now also brings 2 practices. A preset sets the practice rounds (seeding on the best 3 laps in a row), qualifying, finals, bump-up and lap limits in one pick, and its description is shown under the choice in the new-race wizard and in Manage race. Values follow the handbooks in spirit and stay editable.
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.89.34",
"version": "1.89.35",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.89.34",
"version": "1.89.35",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.89.34",
"version": "1.89.35",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+2
View File
@@ -2609,6 +2609,7 @@ const TRANSLATIONS = {
"events.final_standings": "Final-ranking",
"events.generated_qualifying": "Kvalheat skapade från ranking.",
"events.finals_generated": "Finaler skapade från ranking.",
"events.finals_regenerate_confirm": "{count} finaler har redan körts ({names}). Deras varv och resultat raderas om finalerna görs om. Fortsätta?",
"events.bumps_applied": "Bump-ups applicerade till nästa final.",
"events.no_bumps_applied": "Inga bump-ups kunde appliceras ännu.",
"events.no_practice_results": "Inga practice-resultat ännu.",
@@ -4987,6 +4988,7 @@ const TRANSLATIONS = {
"events.final_standings": "Final standings",
"events.generated_qualifying": "Qualifying heats generated from standings.",
"events.finals_generated": "Finals generated from standings.",
"events.finals_regenerate_confirm": "{count} finals have already run ({names}). Their laps and results are deleted if the finals are made again. Continue?",
"events.bumps_applied": "Bump-ups applied to the next main.",
"events.no_bumps_applied": "No bump-ups could be applied yet.",
"events.no_practice_results": "No practice results yet.",
+19 -2
View File
@@ -82,6 +82,21 @@ const DECODER_ROLES = {
pit_exit: { urlKey: "pitExitWsUrl", connectedKey: "pitExitConnected", messageKey: "pitExitLastMessageAt", errorKey: "pitExitLastError" },
};
// One transponder can belong to several drivers (the same person entered in 2WD and 4WD):
// the one in this heat wins, then the race's entry list, then the race's class, then a club
// driver before a guest. Without this the first match in the club list took the lap and,
// not being in the heat, it was thrown away as an unknown transponder.
export function pickDriverForTransponder(drivers = [], transponder, { session = null, event = null } = {}) {
const wanted = String(transponder || "").trim();
const matches = drivers.filter((driver) => wanted && String(driver.transponder || "").trim() === wanted);
if (matches.length <= 1) return matches[0] || null;
const inHeat = new Set(Array.isArray(session?.driverIds) ? session.driverIds : []);
const entered = new Set(event?.raceConfig?.participantsConfigured ? event.raceConfig.driverIds || [] : []);
const score = (driver) => (inHeat.has(driver.id) ? 8 : 0) + (entered.has(driver.id) ? 4 : 0)
+ (event?.classId && driver.classId === event.classId ? 2 : 0) + (driver.guestEventId && driver.guestEventId !== event?.id ? 0 : 1);
return matches.reduce((best, driver) => (score(driver) > score(best) ? driver : best));
}
function resolveCompetitor(session, transponder, deps) {
const { state, t, findEventTeamForPassing } = deps;
const sessionType = String(session?.type || "").toLowerCase();
@@ -129,8 +144,10 @@ function resolveCompetitor(session, transponder, deps) {
}
if (session.mode === "race" && sessionType === "team_race") {
const driver = state.drivers.find((d) => d.transponder === transponder) || null;
const car = state.cars.find((c) => c.transponder === transponder) || null;
// Shared transponder: the driver who is on a team in this race.
const candidates = state.drivers.filter((d) => d.transponder === transponder);
const driver = (event && candidates.find((d) => findEventTeamForPassing(event, d.id, car?.id || null))) || candidates[0] || null;
const team = event ? findEventTeamForPassing(event, driver?.id || null, car?.id || null) : null;
if (!team) {
return {
@@ -171,7 +188,7 @@ function resolveCompetitor(session, transponder, deps) {
};
}
const driver = state.drivers.find((d) => d.transponder === transponder);
const driver = pickDriverForTransponder(state.drivers, transponder, { session, event });
if (driver) {
if (!isOpenMonitoringSession && Array.isArray(session.driverIds) && session.driverIds.length && !session.driverIds.includes(driver.id)) {
return {
+9
View File
@@ -839,7 +839,15 @@ export function renderEventManagerView(context) {
alert(messages.join("\n"));
});
// Finals that already ran lose their laps when the finals are made again - ask first.
const confirmDropRunFinals = () => {
const run = getSessionsForEvent(event.id).filter((s) => s.type === "final" && s.generated
&& (s.status !== "ready" || Object.keys(state.resultsBySession[s.id]?.competitors || {}).length));
return !run.length || window.confirm(t("events.finals_regenerate_confirm", { count: run.length, names: run.map((s) => s.name).join(", ") }));
};
document.getElementById("generateFinals")?.addEventListener("click", () => {
if (!confirmDropRunFinals()) return;
const created = generateFinalsForRace(event);
saveState();
rerenderEventManager(eventId);
@@ -849,6 +857,7 @@ export function renderEventManagerView(context) {
});
document.getElementById("clearGeneratedFinals")?.addEventListener("click", () => {
if (!confirmDropRunFinals()) return;
clearGeneratedFinals(event.id);
saveState();
rerenderEventManager(eventId);
+28 -1
View File
@@ -2,7 +2,7 @@ import { decoderDiagnostics } from "../src/decoder_diagnostics.js";
import test from "node:test";
import assert from "node:assert/strict";
import { connectDecoderHelper, processDecoderMessageHelper } from "../src/decoder_runtime.js";
import { connectDecoderHelper, processDecoderMessageHelper, pickDriverForTransponder } from "../src/decoder_runtime.js";
import { ensureSessionResult } from "../src/timing_logic.js";
function createHarness(options = {}) {
@@ -308,3 +308,30 @@ test("practice hype: 50 laps calls a lap milestone; a race session never gets hy
for (let lap = 1; lap <= 50; lap += 1) race.passing(1_000 + lap * (20_000 - lap * 10), "main");
assert.equal(race.audioEvents.some((key) => key.startsWith("practice_")), false);
});
test("one transponder on two drivers (2WD and 4WD): the 4WD heat's driver gets the lap, not the first in the club list", () => {
const harness = createHarness({ sessionType: "final" });
harness.state.drivers = [
{ id: "d_2wd", name: "Kalle 2WD", classId: "c2", transponder: "777" },
{ id: "d_4wd", name: "Kalle 4WD", classId: "c4", transponder: "777" },
{ id: "other", name: "Other", classId: "c4", transponder: "888" },
];
harness.session.driverIds = ["d_4wd", "other"];
harness.passing(2_000, "main", "777");
harness.passing(22_000, "main", "777");
const competitors = Object.values(harness.state.resultsBySession.session_1.competitors);
assert.deepEqual(competitors.map((entry) => entry.driverId), ["d_4wd"]);
assert.equal(harness.audioEvents.includes("unknown_transponder"), false);
});
test("shared transponder without a heat list: the race's entry list, then its class, then a club driver before a guest", () => {
const drivers = [
{ id: "guest", transponder: "5", classId: "c4", guestEventId: "other_event" },
{ id: "a", transponder: "5", classId: "c2" },
{ id: "b", transponder: " 5 ", classId: "c4" },
];
assert.equal(pickDriverForTransponder(drivers, "5", { event: { classId: "c4" } }).id, "b");
assert.equal(pickDriverForTransponder(drivers, "5", { event: { classId: "c4", raceConfig: { participantsConfigured: true, driverIds: ["a"] } } }).id, "a");
assert.equal(pickDriverForTransponder(drivers, "5", { session: { driverIds: ["guest"] } }).id, "guest");
assert.equal(pickDriverForTransponder(drivers, "9"), null);
});