diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da95e7..b8d5f99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.84.0 + +- **Create finals from Race Day:** when the last qualifying heat of a race has run (or its practice, when the finals are seeded from practice) and it has no finals yet, Race Day shows **đ All qualifying run â create finals** next to the heat controls. It does the same as Manage â Format â Create finals from qualifying and takes you to the first final. + ## 1.83.0 - **Results to House of RC:** a race made from House of RC has **đ€ Send results to House of RC** under Manage â Participants. It previews what each entry gets â qualifying placing (TQ), placing and main, every heat with laps, time and best lap â and sends it in one go; if House of RC refuses anything, nothing is written and the reason is shown. diff --git a/package-lock.json b/package-lock.json index 99a1863..ab760a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.83.0", + "version": "1.84.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.83.0", + "version": "1.84.0", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index 9fdc9b1..afe6f33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.83.0", + "version": "1.84.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 e3a97cd..9297af1 100644 --- a/src/app.js +++ b/src/app.js @@ -5,7 +5,7 @@ import { escapeHtml } from "./html_escape.js"; import { getOverlayModeLabel, buildOverlayPanels, renderOverlaySidePanel, renderOverlayLeaderboard, renderTeamOverlay, renderObsOverlay } from "./overlays.js"; import { renderSettings, openSettingsTab } from "./settings.js"; -import { buildRaceDayQueue, buildRaceDayPreflight, getRaceDriverIds } from "./race_day_logic.js"; +import { buildRaceDayQueue, buildRaceDayPreflight, getRaceDriverIds, shouldOfferFinals } from "./race_day_logic.js"; import { recordTransponderSighting, buildWarmupCheck, createPrologue, getPrologueRemainingMs, holdPrologue, resumePrologue, setPrologueRemaining, takeDuePrologueCall, formatPrologueTime, getPrologueHandoverMs, normalizePrologueSec, getPrologueMarks } from "./prologue_logic.js"; import { findTransponderConflict, getDriverProfileId } from "./driver_profile_logic.js"; import { renderRaceDayView, refreshRaceDayWarmup, refreshRaceDayPrologueClock, updateRaceDayStartDisplay, refreshRaceDayLive } from "./race_day_view.js"; @@ -21,7 +21,7 @@ import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudio import { renderRaceFormatField, renderRaceFormatContextCard, getRaceSummaryItems, getRaceSummaryWarnings, renderManageStatusBadge, renderRaceWizardSteps, renderRaceWizardContent, renderRaceStandingsTable } from "./race_setup_ui.js"; -import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, applyBumpsForRace as applyBumpsForRaceLogic, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder, planSeedingGroups } from "./event_race_logic.js"; +import { normalizeRaceTeam as normalizeRaceTeamLogic, normalizeStoredRacePreset as normalizeStoredRacePresetLogic, getRaceFormatPresets as getRaceFormatPresetsLogic, applyRaceFormatPreset as applyRaceFormatPresetLogic, buildRaceFormatConfigFromForm as buildRaceFormatConfigFromFormLogic, normalizeEvent as normalizeEventLogic, normalizeBrandingConfig as normalizeBrandingConfigLogic, resolveEventBranding as resolveEventBrandingLogic, getRaceManageStatuses as getRaceManageStatusesLogic, buildDefaultRaceWizardDraft as buildDefaultRaceWizardDraftLogic, getRaceWizardPreset as getRaceWizardPresetLogic, applyRaceWizardPresetDefaults as applyRaceWizardPresetDefaultsLogic, ensureRaceParticipantsConfigured as ensureRaceParticipantsConfiguredLogic, buildRaceSession as buildRaceSessionLogic, buildOpenPracticeBundle as buildOpenPracticeBundleLogic, buildTrackSession as buildTrackSessionLogic, createSponsorRounds as createSponsorRoundsLogic, buildRaceSessionsFromWizard as buildRaceSessionsFromWizardLogic, getRaceWizardSessionPlan as getRaceWizardSessionPlanLogic, getEventDrivers as getEventDriversLogic, getEventTeams as getEventTeamsLogic, getTeamDriverPool as getTeamDriverPoolLogic, reassignTeamMembers as reassignTeamMembersLogic, findEventTeamForPassing as findEventTeamForPassingLogic, generateQualifyingForRace as generateQualifyingForRaceLogic, reseedUpcomingQualifying as reseedUpcomingQualifyingLogic, moveDriversIntoQualifyingHeat as moveDriversIntoQualifyingHeatLogic, parseQualifyingHeatName as parseQualifyingHeatNameLogic, generateFinalsForRace as generateFinalsForRaceLogic, applyBumpsForRace as applyBumpsForRaceLogic, orderSessionsForRunning, buildEventSchedule as buildEventScheduleLogic, normalizeHeatOrder, planSeedingGroups } from "./event_race_logic.js"; import { getFinishWait as getFinishWaitLogic, getSessionTypeLabel as getSessionTypeLabelLogic, getStatusLabel as getStatusLabelLogic, isUntimedSession as isUntimedSessionLogic, getActiveSession as getActiveSessionLogic, getLiveSession as getLiveSessionLogic, getSessionTargetMs as getSessionTargetMsLogic, getSessionLapWindow as getSessionLapWindowLogic, isCountedPassing as isCountedPassingLogic, getVisiblePassings as getVisiblePassingsLogic, getPassingValidationLabel as getPassingValidationLabelLogic, getSessionTiming as getSessionTimingLogic, ensureSessionResult as ensureSessionResultLogic, buildLeaderboard as buildLeaderboardLogic, formatLapDelta as formatLapDeltaLogic, formatLeaderboardGap as formatLeaderboardGapLogic, getCompetitorElapsedMs as getCompetitorElapsedMsLogic, getCompetitorPassings as getCompetitorPassingsLogic, getCompetitorSeedMetric as getCompetitorSeedMetricLogic, getSessionEntrants as getSessionEntrantsLogic, buildPracticeStandings as buildPracticeStandingsLogic, getQualifyingPointsValue as getQualifyingPointsValueLogic, isHighPointsTable as isHighPointsTableLogic, compareNumberSet as compareNumberSetLogic, buildQualifyingTieBreakNote as buildQualifyingTieBreakNoteLogic, hasQualifyingPrimaryTie as hasQualifyingPrimaryTieLogic, buildQualifyingStandings as buildQualifyingStandingsLogic, formatTeamActiveMemberLabel as formatTeamActiveMemberLabelLogic, buildTeamRaceStandings as buildTeamRaceStandingsLogic, buildSessionChannelStats as buildSessionChannelStatsLogic, buildTeamStintLog as buildTeamStintLogLogic, getSessionGridEntries as getSessionGridEntriesLogic, getSessionGridOrder as getSessionGridOrderLogic, ensureSessionDriverOrder as ensureSessionDriverOrderLogic, buildFinalStandings as buildFinalStandingsLogic, getTrackRecordMs as getTrackRecordMsLogic } from "./timing_logic.js"; import { normalizeTrackLayouts, getTrackLayoutIdAt, getTrackLayoutLabel, nextTrackLayoutLabel, findRaceSessionBlockingLayoutChange, isPracticeSessionType, isTrackLayoutInUse } from "./track_layouts_logic.js"; @@ -754,6 +754,13 @@ const renderRaceDay = () => renderRaceDayView({ renderDaySchedule, bindDaySchedule, renderDayCall, bindDayCall, setCompetitorLapStatus, ...speakerPanelDeps, + shouldOfferFinals: (eventId) => shouldOfferFinals(state, eventId), + createFinalsForEvent: (eventId) => { + const event = state.events.find((item) => item.id === eventId); + if (!event || !generateFinalsForRace(event)) return null; + saveState(); + return orderSessionsForRunning(getSessionsForEvent(eventId), event.sessionOrder).find((session) => session.type === "final") || null; + }, renderRaceOverview: (session) => renderRaceOverviewFor(state.events.find((event) => event.id === session?.eventId)), bindRaceOverview: (root, session) => bindRaceOverviewFor(root, state.events.find((event) => event.id === session?.eventId)), addTrackLayout, renderView, state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock, @@ -1296,6 +1303,8 @@ const TRANSLATIONS = { "race_day.go_next": "NĂ€sta: {name}", "race_day.hidden_sessions": "({count} frĂ„n andra dagar dolda)", "race_day.restart_session": "Kör om", + "race_day.create_finals": "Alla kval Ă€r körda â skapa finaler", + "race_day.create_finals_hint": "Skapar A-, B- och C-finaler frĂ„n kvalresultatet, samma som Hantera â Format â Skapa finaler frĂ„n kval.", "race_day.reset_session_hint": "Avbrutet eller klart heat, kval eller final: varv, resultat och klocka nollstĂ€lls och den kan startas igen.", "race_day.reset_session_confirm": "Kör om \"{name}\"?\n\nAlla varv och resultat nollstĂ€lls och klockan stĂ„r pĂ„ noll - sedan trycker du Starta. Det gĂ„r inte att Ă„ngra.", "race_day.new_practice_day": "NollstĂ€ll â ny trĂ€ningsdag", @@ -2305,7 +2314,7 @@ const TRANSLATIONS = { "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_8": "8. NĂ€r alla kval Ă€r körda: tryck đ Alla kval Ă€r körda â skapa finaler pĂ„ Race Day (eller Hantera â Format â 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.", @@ -3535,6 +3544,8 @@ const TRANSLATIONS = { "race_day.go_next": "Next: {name}", "race_day.hidden_sessions": "({count} from other days hidden)", "race_day.restart_session": "Run again", + "race_day.create_finals": "All qualifying run â create finals", + "race_day.create_finals_hint": "Creates the A, B and C finals from the qualifying results, same as Manage â Format â Create finals from qualifying.", "race_day.reset_session_hint": "A stopped or finished heat, qualifier or final: laps, results and clock are reset and it can be started again.", "race_day.reset_session_confirm": "Run \"{name}\" again?\n\nEvery lap and result is cleared and the clock is back at zero - then press Start. This cannot be undone.", "race_day.new_practice_day": "Reset â new practice day", @@ -4544,7 +4555,7 @@ const TRANSLATIONS = { "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_8": "8. When all qualifying has run: press đ All qualifying run â create finals on Race Day (or Manage â Format â Create 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.", diff --git a/src/race_day_logic.js b/src/race_day_logic.js index 26cc3f6..633b30b 100644 --- a/src/race_day_logic.js +++ b/src/race_day_logic.js @@ -159,3 +159,17 @@ export function buildRaceDayPreflight(state, session, { backendAvailable = false return { ready: !checks.some((item) => item.level === "error"), checks }; } + +// Race Day offers "Create finals" once every heat the finals are seeded from (qualifying, or +// practice when the race seeds finals from practice) has run and the race has no finals yet. +// Not for practice-only races or sponsor events, which have their own flow. +export function shouldOfferFinals(state, eventId) { + const event = (state?.events || []).find((item) => item.id === eventId); + if (!event || event.raceConfig?.practiceOnly || event.mode === "track") return false; + const sessions = (state.sessions || []).filter((session) => session.eventId === eventId); + const sourceType = event.raceConfig?.finalsSource === "practice" ? "practice" : "qualification"; + const source = sessions.filter((session) => session.type === sourceType); + return source.length > 0 + && source.every((session) => ["finished", "stopped"].includes(session.status)) + && !sessions.some((session) => session.type === "final"); +} diff --git a/src/race_day_view.js b/src/race_day_view.js index b6579fc..aad414c 100644 --- a/src/race_day_view.js +++ b/src/race_day_view.js @@ -266,6 +266,7 @@ export function renderRaceDayView(deps) { renderDaySchedule = () => "", bindDaySchedule = () => {}, renderDayCall = () => "", bindDayCall = () => {}, renderRaceOverview = () => "", bindRaceOverview = () => {}, renderSpeakerPanel = () => "", bindSpeakerPanel = () => {}, + shouldOfferFinals = () => false, createFinalsForEvent = () => null, } = deps; const queue = buildRaceDayQueue(state); const session = queue.current; @@ -344,6 +345,7 @@ export function renderRaceDayView(deps) { ${sessionChoices.hidden || showAllSessions ? `` : ""} ${session && !isSelected ? `` : ""}