diff --git a/CHANGELOG.md b/CHANGELOG.md index 9528092..bd14e36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.58.0 - 2026-11-04 + +### Added + +- Guide → Create a race: a new "Race day step by step" section covering practice, qualifying with a flying start, finals, and what to tick to run only some of the steps. + +### Fixed + +- Create race (wizard) builds qualifying as real heats (Q1 H1, Q1 H2 …) split by drivers per heat, instead of one "Kval N" session per round with the whole class. "Generate qualifying from practice" now replaces them instead of adding duplicate heats. + ## 1.57.1 - 2026-11-03 ### Fixed diff --git a/package-lock.json b/package-lock.json index 785c751..826ddf4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.57.1", + "version": "1.58.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.57.1", + "version": "1.58.0", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index c13c845..61fc4ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.57.1", + "version": "1.58.0", "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 69690e1..e5dcea4 100644 --- a/src/app.js +++ b/src/app.js @@ -2060,12 +2060,22 @@ const TRANSLATIONS = { "guide.schedule_2": "2. Varje sessions planerade klockslag räknas ut i körordning (practice, sedan kval, sedan finaler) utifrån starttiden, sessionens längd/efterlöp och pausen mellan sessioner.", "guide.schedule_3": "3. Så fort en session faktiskt startar eller avslutas flyttas resten av schemat automatiskt fram till den verkliga tiden - en sen start eller en session som drar över (inklusive paus) skjuter resten av dagen framåt utan att du behöver räkna om manuellt. En session som startade mer än en minut sent märks \"Försenad\".", "guide.schedule_4": "4. Det planerade klockslaget skrivs också ut på startlistorna (Skriv ut/PDF startlistor) så förare kan se när deras session ungefär börjar.", + "guide.day_flow_title": "Racedag steg för steg: practice → kval → finaler", + "guide.day_flow_1": "1. Förbered: klassen och förarna med sina transpondrar under Förare, och dekodern ansluten. Kör flera klasser samma dag? Skapa ett race per klass med samma datum.", + "guide.day_flow_2": "2. Race Setup → Skapa race. Ange namn, datum och klass och välj en preset, till exempel Klubbrace kval + final. Den ger flygande start i kvalet: alla kör ut, och varje förares egna 5 minuter startar vid förarens första passering över slingan efter startsignalen. Finalerna får positionsstart.", + "guide.day_flow_3": "3. Kryssa i förarna som ska vara med i racet.", + "guide.day_flow_4": "4. Välj vad som ska köras. Practice + kval: practice blir seedning för kvalheaten. Bara kval: kryssa ur practice, så delas kvalheaten upp direkt från deltagarlistan. Bara practice + finaler: kryssa ur kval och välj Källa för finaler = Practice i Raceformat.", + "guide.day_flow_5": "5. Kvalet skapas direkt som riktiga heat (Q1 H1, Q1 H2 …) enligt Förare per kvalheat och Antal kvalrundor. Antal varv, tider och starttyp kan finjusteras under Hantera → Raceformat.", + "guide.day_flow_6": "6. När practice är kört: Hantera → Skapa kval från practice. Kvalheaten byggs då om efter practice-resultatet och ersätter de gamla, så inga dubbletter uppstår. Hoppar du över det körs kvalet i deltagarlistans ordning.", + "guide.day_flow_7": "7. Kör kvalet på Race Day. Flest varv vinner och vid lika antal varv vinner lägst total tid. Vill du sortera om kommande heat efter aktuell ranking: Reseeda kommande kval.", + "guide.day_flow_8": "8. När alla kval är körda: Hantera → Skapa finaler från kval. A-, B- och C-finaler byggs enligt Förare per final, antal finalheat och räknade finalheat.", + "guide.day_flow_9": "9. Kör finalerna, lägsta finalen först. Vid gridstart räknar speakern ner 10 … 3, säger \"Start på tonen\" och sedan kommer tonen. Med bump-ups: Applicera bump-ups när en lägre final är klar. Dagens schema på Race Day lägger alla klasser i en körordning med tider.", "guide.race_wizard_title": "Create Race Wizard", "guide.race_wizard_1": "1. Börja i Race Setup och använd wizarden när du skapar ett nytt race, i stället för att bygga allt direkt i Hantera.", "guide.race_wizard_2": "2. Steg 1 sätter namn, datum, klass och preset. Presetet fyller rimliga standardvärden innan du finjusterar något.", "guide.race_wizard_3": "3. Steg 2 väljer exakt vilka förare som ska vara giltiga i racet. De blir då race-specifika deltagare och filter för timing/seedning.", "guide.race_wizard_4": "4. Steg 3 väljer vilka sessioner som ska skapas direkt: practice, kval och/eller team race beroende på preset.", - "guide.race_wizard_5": "5. Wizarden skapar de första sessionerna automatiskt. Finaler skapas senare från Race actions när kval eller practice är klara.", + "guide.race_wizard_5": "5. Wizarden skapar de första sessionerna automatiskt, kvalet som heat (Q1 H1, Q1 H2 …). Finaler skapas senare från Race actions när kval eller practice är klara.", "guide.race_wizard_6": "6. Efter skapandet går du vidare till Hantera för raceformat, generering, grid, standings och utskrift.", "guide.race_wizard_7": "7. I Hantera -> Race actions kan du exportera eller importera ett enskilt racepaket om du vill flytta just det racet till en annan installation.", "guide.manage_steps_title": "Hantera race i fyra steg", @@ -4029,12 +4039,22 @@ const TRANSLATIONS = { "guide.schedule_2": "2. Every session's planned clock time is worked out in running order (practice, then qualifying, then finals) from the start time, each session's own duration/follow-up, and the gap between sessions.", "guide.schedule_3": "3. As soon as a session actually starts or finishes, the rest of the schedule automatically shifts to match reality - a late start or a session that runs long (including any pause) pushes the rest of the day forward with no manual recalculation. A session that started more than a minute late is marked \"Delayed\".", "guide.schedule_4": "4. The planned clock time is also printed on the start lists (Print/PDF start lists) so drivers can see roughly when their session begins.", + "guide.day_flow_title": "Race day step by step: practice → qualifying → finals", + "guide.day_flow_1": "1. Prepare: the class and the drivers with their transponders under Drivers, and the decoder connected. Several classes on one day? Create one race per class with the same date.", + "guide.day_flow_2": "2. Race Setup → Create race. Enter name, date and class and pick a preset, for example Club race qual + finals. It gives qualifying a flying start: everyone drives out, and each driver's own 5 minutes start at their first crossing of the loop after the start signal. Finals get a position start.", + "guide.day_flow_3": "3. Tick the drivers who take part in the race.", + "guide.day_flow_4": "4. Choose what to run. Practice + qualifying: practice seeds the qualifying heats. Qualifying only: untick practice and the heats are split straight from the entry list. Practice + finals only: untick qualifying and set Source for finals = Practice under Race format.", + "guide.day_flow_5": "5. Qualifying is created straight away as real heats (Q1 H1, Q1 H2 …) by Drivers per qualifying heat and Qualifying rounds. Laps, times and start type can be fine-tuned under Manage → Race format.", + "guide.day_flow_6": "6. When practice has run: Manage → Generate qualifying from practice. The heats are rebuilt from the practice result and replace the old ones, so nothing is duplicated. Skip it and qualifying runs in entry-list order.", + "guide.day_flow_7": "7. Run qualifying on Race Day. Most laps wins; on equal laps the lowest total time wins. To re-sort the coming heats by the current ranking: Reseed upcoming qualifying.", + "guide.day_flow_8": "8. When all qualifying has run: Manage → Generate finals from qualifying. A, B and C finals are built by Drivers per final, final legs and counted legs.", + "guide.day_flow_9": "9. Run the finals, lowest final first. On a grid start the announcer counts 10 … 3, says \"Starting to the sound of the tone\" and the tone follows. With bump-ups: Apply bump-ups when a lower final is done. Today's schedule on Race Day puts every class in one running order with times.", "guide.race_wizard_title": "Create Race Wizard", "guide.race_wizard_1": "1. Start in Race Setup and use the wizard when creating a new race instead of building everything directly in Manage.", "guide.race_wizard_2": "2. Step 1 sets name, date, class and preset. The preset fills sensible defaults before you fine-tune anything.", "guide.race_wizard_3": "3. Step 2 selects exactly which drivers should be valid for this race. They then become the race-specific participant scope for timing and seeding.", "guide.race_wizard_4": "4. Step 3 chooses which sessions should be created immediately: practice, qualifying and/or team race depending on the preset.", - "guide.race_wizard_5": "5. The wizard creates the initial sessions automatically. Finals are generated later from Race Actions after qualifying or practice is complete.", + "guide.race_wizard_5": "5. The wizard creates the initial sessions automatically, qualifying as heats (Q1 H1, Q1 H2 …). Finals are generated later from Race Actions after qualifying or practice is complete.", "guide.race_wizard_6": "6. After creation, continue in Manage for race format, generation, grid, standings and print/export.", "guide.race_wizard_7": "7. In Manage -> Race Actions you can export or import a single race package when you want to move just that race to another installation.", "guide.manage_steps_title": "Manage Race In Four Steps", @@ -6717,6 +6737,7 @@ function renderEventWorkspace(mode) { applyRaceFormatPreset, buildOpenPracticeBundle, buildRaceSessionsFromWizard, + generateQualifyingForRace, buildDefaultRaceWizardDraft, applyRaceWizardPresetDefaults, setSelectedTeamEditId: (value) => { selectedTeamEditId = value; }, diff --git a/src/event_race_logic.js b/src/event_race_logic.js index eb8f5b6..bd2c106 100644 --- a/src/event_race_logic.js +++ b/src/event_race_logic.js @@ -530,7 +530,6 @@ export function buildRaceSessionsFromWizard(event, draft, { t, buildRaceSession const driverIds = event.raceConfig.driverIds || []; const created = []; const practiceCount = Math.max(0, Number(draft.practiceSessions || 0) || 0); - const qualRounds = Math.max(0, Number(draft.qualifyingRounds || 0) || 0); if (draft.createPractice && practiceCount > 0) { for (let index = 1; index <= practiceCount; index += 1) { created.push( @@ -542,19 +541,9 @@ export function buildRaceSessionsFromWizard(event, draft, { t, buildRaceSession ); } } - if (draft.createQualifying && qualRounds > 0) { - for (let index = 1; index <= qualRounds; index += 1) { - created.push( - buildRaceSession(event.id, `${t("session.qualification")} ${index}`, "qualification", event.raceConfig.qualDurationMin, { - driverIds, - startMode: event.raceConfig.qualStartMode, - seedBestLapCount: event.raceConfig.qualSeedLapCount, - seedMethod: event.raceConfig.qualSeedMethod, - followUpSec: event.raceConfig.followUpSec, - }) - ); - } - } + // Qualifying is not built here: the wizard sets raceConfig.qualifyingRounds and calls + // generateQualifyingForRace, so the heats are split per "drivers per heat" and named + // Q H - and "Create qualifying from practice" later replaces them. if (draft.createTeamRace) { created.push( buildRaceSession(event.id, t("events.team_race"), "team_race", Math.max(1, Number(draft.teamRaceDurationMin || event.raceConfig.finalDurationMin || 1)), { diff --git a/src/event_workspace_controller.js b/src/event_workspace_controller.js index 9d00832..b4653f6 100644 --- a/src/event_workspace_controller.js +++ b/src/event_workspace_controller.js @@ -44,6 +44,7 @@ export function renderEventWorkspaceView(context) { applyRaceFormatPreset, buildOpenPracticeBundle, buildRaceSessionsFromWizard, + generateQualifyingForRace, buildDefaultRaceWizardDraft, applyRaceWizardPresetDefaults, setSelectedTeamEditId, @@ -259,6 +260,11 @@ export function renderEventWorkspaceView(context) { event.raceConfig.participantsConfigured = true; state.events.push(event); buildRaceSessionsFromWizard(event, draft).forEach((session) => state.sessions.push(session)); + const qualRounds = Math.max(0, Number(draft.qualifyingRounds || 0) || 0); + if (draft.createQualifying && qualRounds > 0) { + event.raceConfig.qualifyingRounds = qualRounds; + generateQualifyingForRace(event); + } setSelectedTeamEditId(null); setSelectedSessionEditId(null); setRaceWizardDraft(applyRaceWizardPresetDefaults(buildDefaultRaceWizardDraft(), "club_qualifying")); diff --git a/src/misc_views.js b/src/misc_views.js index 68c57d9..9e4d027 100644 --- a/src/misc_views.js +++ b/src/misc_views.js @@ -82,6 +82,10 @@ export function renderGuideView({ dom, t }) {
+
+ ${renderGuidePanel("guide.day_flow_title", ["guide.day_flow_1", "guide.day_flow_2", "guide.day_flow_3", "guide.day_flow_4", "guide.day_flow_5", "guide.day_flow_6", "guide.day_flow_7", "guide.day_flow_8", "guide.day_flow_9"], "", { t })} +
+
${renderGuidePanel("guide.sponsor_title", ["guide.sponsor_1", "guide.sponsor_2", "guide.sponsor_3", "guide.sponsor_4", "guide.sponsor_5", "guide.sponsor_6"], "", { t })} ${renderGuidePanel("guide.race_title", ["guide.race_1", "guide.race_2", "guide.race_3", "guide.race_4", "guide.race_4a", "guide.race_5", "guide.race_6", "guide.race_7", "guide.race_8", "guide.race_9", "guide.race_10"], "", { t })} diff --git a/tests/browser_race_setup.js b/tests/browser_race_setup.js index cf7d67b..f99ddb4 100644 --- a/tests/browser_race_setup.js +++ b/tests/browser_race_setup.js @@ -38,6 +38,27 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState, await click("raceWizardCreate"); await waitFor(async () => Boolean(await findEvent("Browser Endurance")), "wizard race creation"); const race = await findEvent("Browser Endurance"); + // A wizard race with practice + qualifying: the qualifying is real heats (Q H, + // generated), so "Create qualifying from practice" later replaces them instead of adding more. + await navigate("race_setup", "raceWizardStepForm"); + await fill("raceWizardStepForm", { name: "Browser Club Race", date: "2026-09-08", classId: "test_class", presetId: "club_qualifying" }); + await click("raceWizardNext"); + await click("wizardSelectAllParticipants"); + await click("raceWizardNext"); + await evaluate('(() => { const form = document.getElementById("raceWizardPlanForm"); form.elements.createPractice.checked = true; form.elements.createQualifying.checked = true; form.elements.createPractice.dispatchEvent(new Event("change", { bubbles: true })); form.elements.createQualifying.dispatchEvent(new Event("change", { bubbles: true })); })()'); + await fill("raceWizardPlanForm", { practiceSessions: "1", qualifyingRounds: "2" }); + await click("raceWizardNext"); + await click("raceWizardCreate"); + await waitFor(async () => Boolean(await findEvent("Browser Club Race")), "wizard club race creation"); + { + const club = await findEvent("Browser Club Race"); + const clubSessions = (await savedState()).sessions.filter((session) => session.eventId === club.id); + const quals = clubSessions.filter((session) => session.type === "qualification"); + assert.equal(clubSessions.filter((session) => session.type === "practice").length, 1, "one practice"); + assert.ok(quals.length >= 2 && quals.every((session) => /^Q[12] H\d+$/.test(session.name) && session.generated), `qualifying heats per round: ${quals.map((session) => session.name)}`); + assert.equal(club.raceConfig.qualifyingRounds, 2); + console.log("PASS wizard builds qualifying as Q H heats"); + } await navigate("race_setup", "raceWizardStepForm"); await editEvent(race, "race_setup", "raceWizardStepForm"); const current = await savedState(); @@ -89,7 +110,7 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState, for (const name of ["Q1 H2", "Q1 H1"]) { await fill("sessionForm", { name, type: "qualification", durationMin: "5" }); await submit("sessionForm"); - await waitFor(async () => (await savedState()).sessions.some((item) => item.name === name), name + " created"); + await waitFor(async () => (await savedState()).sessions.some((item) => item.name === name && item.eventId === race.id), name + " created"); } const listed = async () => evaluate(`[...document.querySelectorAll("[data-session-move][data-step='1']")].map((button) => button.dataset.sessionMove)`); const sessionNames = async () => { @@ -98,10 +119,10 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState, return ids.map((id) => all.find((item) => item.id === id)?.name).filter((name) => /^Q1/.test(name)); }; await waitFor(async () => (await sessionNames()).join() === "Q1 H1,Q1 H2", "listed in running order although Q1 H1 was made last"); - const q12 = (await savedState()).sessions.find((item) => item.name === "Q1 H2"); + const q12 = (await savedState()).sessions.find((item) => item.name === "Q1 H2" && item.eventId === race.id); await evaluate(`document.querySelector('[data-session-move="${q12.id}"][data-step="-1"]').click()`); await waitFor(async () => (await sessionNames()).join() === "Q1 H2,Q1 H1", "Q1 H2 moved up"); - const q11 = (await savedState()).sessions.find((item) => item.name === "Q1 H1"); + const q11 = (await savedState()).sessions.find((item) => item.name === "Q1 H1" && item.eventId === race.id); await waitFor(async () => { const order = (await raceState()).sessionOrder || []; return order.includes(q12.id) && order.indexOf(q12.id) < order.indexOf(q11.id); diff --git a/tests/race_timing_logic.test.js b/tests/race_timing_logic.test.js index cd06f17..11760a6 100644 --- a/tests/race_timing_logic.test.js +++ b/tests/race_timing_logic.test.js @@ -303,20 +303,10 @@ test("race wizard creates configured practice, qualifying, and endurance session { t: (key) => key, buildRaceSession } ); - assert.equal(sessions.length, 6); - assert.deepEqual(sessions.map((session) => session.type), [ - "practice", - "practice", - "qualification", - "qualification", - "qualification", - "team_race", - ]); - assert.equal(sessions[2].durationMin, 6); - assert.equal(sessions[2].seedMethod, "consecutive"); - assert.equal(sessions[2].followUpSec, 20); - assert.equal(sessions[5].durationMin, 180); - assert.deepEqual(sessions[5].driverIds, ["driver_1", "driver_2"]); + // Qualifying heats come from generateQualifyingForRace (split per heat), not from here. + assert.deepEqual(sessions.map((session) => session.type), ["practice", "practice", "team_race"]); + assert.equal(sessions[2].durationMin, 180); + assert.deepEqual(sessions[2].driverIds, ["driver_1", "driver_2"]); }); test("qualifying generation splits seeded drivers into every configured round", () => {