fix(race): never remake qualifying or finals that have already run; clearing them asks first (1.89.36)
This commit is contained in:
1 parent
01abe5b7ae
commit
93c590e5b8
8 files changed
+66
-17
No files matched your search
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.36
|
||||
|
||||
### Fixed
|
||||
|
||||
- Qualifying and finals that have already started running are never made again by mistake: Generate qualifying / Generate finals (Manage race, the series rounds, sponsor events) now refuse and say which heats have run, instead of deleting them with their laps. To really redo them, Clear generated ... first - it names the run heats and asks before deleting.
|
||||
|
||||
## 1.89.35
|
||||
|
||||
### Fixed
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.35",
|
||||
"version": "1.89.36",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.35",
|
||||
"version": "1.89.36",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.35",
|
||||
"version": "1.89.36",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
+13
-3
@@ -32,7 +32,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, orderSessionsForRunning, 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, getRunGeneratedSessions, 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";
|
||||
@@ -111,6 +111,8 @@ const parseQualifyingHeatName = (name) => parseQualifyingHeatNameLogic(name);
|
||||
const findEventTeamForPassing = (event, driverId, carId) => findEventTeamForPassingLogic(event, driverId, carId, { getEventTeams });
|
||||
const generateQualifyingForRace = (event) => generateQualifyingForRaceLogic(event, { buildPracticeStandings, getEventDrivers, state, normalizeStartMode, normalizeSession, uid, chunkArray, clearGeneratedQualifying });
|
||||
const reseedUpcomingQualifying = (event) => reseedUpcomingQualifyingLogic(event, { buildQualifyingStandings, buildPracticeStandings, getEventDrivers, getSessionsForEvent, chunkArray });
|
||||
// Names of the generated heats of a race that already ran ("" = none): then they can't be made again.
|
||||
const runGeneratedHeatNames = (eventId, type) => getRunGeneratedSessions(state.sessions, eventId, type, state.resultsBySession).map((session) => session.name).join(", ");
|
||||
const generateFinalsForRace = (event) => generateFinalsForRaceLogic(event, { buildPracticeStandings, buildQualifyingStandings, clearGeneratedFinals, state, normalizeStartMode, normalizeSession, uid, chunkArray, t });
|
||||
const applyBumpsForRace = (event) => applyBumpsForRaceLogic(event, { buildFinalStandings, getSessionsForEvent });
|
||||
|
||||
@@ -1119,6 +1121,8 @@ const addDriverToSeriesRound = (series, eventId, { name, transponder }) => {
|
||||
const generateSeriesRoundQualifying = (eventId) => {
|
||||
const event = findSeriesEvent(eventId);
|
||||
if (!event) return 0;
|
||||
const run = runGeneratedHeatNames(eventId, "qualification");
|
||||
if (run) { window.alert(t("events.qualifying_already_run", { names: run })); return -1; }
|
||||
const created = generateQualifyingForRace(event);
|
||||
saveState();
|
||||
return created;
|
||||
@@ -1126,6 +1130,8 @@ const generateSeriesRoundQualifying = (eventId) => {
|
||||
const generateSeriesRoundFinals = (eventId) => {
|
||||
const event = findSeriesEvent(eventId);
|
||||
if (!event) return 0;
|
||||
const run = runGeneratedHeatNames(eventId, "final");
|
||||
if (run) { window.alert(t("events.finals_already_run", { names: run })); return 0; }
|
||||
const created = generateFinalsForRace(event);
|
||||
saveState();
|
||||
return created;
|
||||
@@ -2609,7 +2615,9 @@ 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.finals_already_run": "Finalerna har redan börjat köras ({names}), så de görs inte om – då skulle varv och resultat raderas. Vill ni verkligen göra om dem: tryck först \"Rensa genererade finaler\".",
|
||||
"events.qualifying_already_run": "Kvalet har redan börjat köras ({names}), så det görs inte om – då skulle varv och resultat raderas. Vill ni verkligen göra om det: tryck först \"Rensa genererade kval\".",
|
||||
"events.clear_run_heats_confirm": "{names} har redan körts. Alla deras varv och resultat raderas och går inte att få tillbaka. Rensa ändå?",
|
||||
"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.",
|
||||
@@ -4988,7 +4996,9 @@ 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.finals_already_run": "The finals have already started running ({names}), so they are not made again - that would delete their laps and results. To really redo them, press \"Clear generated finals\" first.",
|
||||
"events.qualifying_already_run": "Qualifying has already started running ({names}), so it is not made again - that would delete its laps and results. To really redo it, press \"Clear generated qualifying\" first.",
|
||||
"events.clear_run_heats_confirm": "{names} have already run. All their laps and results are deleted and cannot be brought back. Clear anyway?",
|
||||
"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.",
|
||||
|
||||
@@ -805,7 +805,14 @@ export function renderEventManagerView(context) {
|
||||
refreshManager();
|
||||
});
|
||||
|
||||
// Heats that already ran: Generate refuses (it would delete their laps), Clear asks first.
|
||||
const runHeatNames = (type) => getSessionsForEvent(event.id).filter((s) => s.type === type && s.generated
|
||||
&& (s.status !== "ready" || Object.keys(state.resultsBySession[s.id]?.competitors || {}).length)).map((s) => s.name).join(", ");
|
||||
const confirmClearRunHeats = (type) => { const run = runHeatNames(type); return !run || window.confirm(t("events.clear_run_heats_confirm", { names: run })); };
|
||||
|
||||
document.getElementById("generateQualifying")?.addEventListener("click", () => {
|
||||
const run = runHeatNames("qualification");
|
||||
if (run) { alert(t("events.qualifying_already_run", { names: run })); return; }
|
||||
const created = generateQualifyingForRace(event);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -815,6 +822,7 @@ export function renderEventManagerView(context) {
|
||||
});
|
||||
|
||||
document.getElementById("clearGeneratedQualifying")?.addEventListener("click", () => {
|
||||
if (!confirmClearRunHeats("qualification")) return;
|
||||
clearGeneratedQualifying(event.id);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -839,15 +847,9 @@ 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 run = runHeatNames("final");
|
||||
if (run) { alert(t("events.finals_already_run", { names: run })); return; }
|
||||
const created = generateFinalsForRace(event);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
@@ -857,7 +859,7 @@ export function renderEventManagerView(context) {
|
||||
});
|
||||
|
||||
document.getElementById("clearGeneratedFinals")?.addEventListener("click", () => {
|
||||
if (!confirmDropRunFinals()) return;
|
||||
if (!confirmClearRunHeats("final")) return;
|
||||
clearGeneratedFinals(event.id);
|
||||
saveState();
|
||||
rerenderEventManager(eventId);
|
||||
|
||||
+10
-2
@@ -794,6 +794,14 @@ export function splitIntoBalancedGroups(items, maxSize) {
|
||||
return groups;
|
||||
}
|
||||
|
||||
// Generated heats of one type that already ran (started, or with laps). Making the heats again
|
||||
// would delete them with their results, so the generators refuse while there are any: the
|
||||
// heats have to be cleared on purpose first (Clear generated ..., which asks).
|
||||
export function getRunGeneratedSessions(sessions = [], eventId, type, resultsBySession = {}) {
|
||||
return sessions.filter((session) => session.eventId === eventId && session.type === type && session.generated
|
||||
&& (session.status !== "ready" || Object.keys(resultsBySession?.[session.id]?.competitors || {}).length > 0));
|
||||
}
|
||||
|
||||
export function generateQualifyingForRace(event, { buildPracticeStandings, getEventDrivers, state, normalizeStartMode, normalizeSession, uid, chunkArray, clearGeneratedQualifying }) {
|
||||
const sourceRows = buildPracticeStandings(event);
|
||||
const fallbackRows =
|
||||
@@ -805,7 +813,7 @@ export function generateQualifyingForRace(event, { buildPracticeStandings, getEv
|
||||
driverName: driver.name,
|
||||
}));
|
||||
|
||||
if (!fallbackRows.length) {
|
||||
if (!fallbackRows.length || getRunGeneratedSessions(state.sessions, event.id, "qualification", state.resultsBySession).length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1024,7 +1032,7 @@ export function generateFinalsForRace(event, { buildPracticeStandings, buildQual
|
||||
? buildPracticeStandings(event)
|
||||
: buildQualifyingStandings(event);
|
||||
|
||||
if (!sourceRows.length) {
|
||||
if (!sourceRows.length || getRunGeneratedSessions(state.sessions, event.id, "final", state.resultsBySession).length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,8 @@ export function mountSponsorSetup(root, deps) {
|
||||
error.textContent = "";
|
||||
const rows = event.raceConfig?.finalsSource === "practice" ? buildPracticeStandings(event) : buildQualifyingStandings(event);
|
||||
if (!rows.length) { error.textContent = t("sponsor.need_results"); return; }
|
||||
const run = getSessionsForEvent(event.id).filter((s) => s.type === "final" && s.generated && s.status !== "ready").map((s) => s.name).join(", ");
|
||||
if (run) { error.textContent = t("events.finals_already_run", { names: run }); return; }
|
||||
if (!generateFinalsForRace(event)) { error.textContent = t("sponsor.need_results"); return; }
|
||||
drawCarsForSessions(getSessionsForEvent(event.id).filter((session) => session.type === "final"), carIds);
|
||||
saveState();
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
buildRaceFormatConfigFromForm,
|
||||
buildRaceSessionsFromWizard,
|
||||
generateFinalsForRace,
|
||||
getRunGeneratedSessions,
|
||||
generateQualifyingForRace,
|
||||
normalizeHeatOrder,
|
||||
getEventDrivers,
|
||||
@@ -1126,3 +1127,23 @@ test("sponsor heats: each row carries the car the driver has in this heat, other
|
||||
assert.equal(sponsor.find((row) => row.key === "b").heatCarName, "", "a car not handed out in this heat is not shown");
|
||||
assert.ok(buildLeaderboard({ id: "club", type: "heat", startMode: "mass" }, deps).every((row) => row.heatCarName === ""));
|
||||
});
|
||||
|
||||
test("finals that already ran are never made again by mistake - Generate refuses until they are cleared on purpose", () => {
|
||||
const ranFinal = { id: "a1", eventId: "event_1", name: "A final 1", type: "final", generated: true, status: "finished" };
|
||||
const readyFinal = { id: "a2", eventId: "event_1", name: "A final 2", type: "final", generated: true, status: "ready" };
|
||||
const state = { sessions: [ranFinal, readyFinal], resultsBySession: { a1: { competitors: { x: { laps: 12 } } } } };
|
||||
let cleared = 0;
|
||||
const created = generateFinalsForRace({ id: "event_1", raceConfig: {} }, {
|
||||
buildPracticeStandings: () => [],
|
||||
buildQualifyingStandings: () => [{ driverId: "d1" }, { driverId: "d2" }],
|
||||
clearGeneratedFinals: () => { cleared += 1; },
|
||||
state, normalizeStartMode, normalizeSession: (session) => session, uid: createUid(), chunkArray, t: (key) => key,
|
||||
});
|
||||
assert.equal(created, 0);
|
||||
assert.equal(cleared, 0, "the run A final 1 and its laps are kept");
|
||||
assert.deepEqual(state.sessions.map((session) => session.id), ["a1", "a2"]);
|
||||
// A heat reset to ready that still holds laps counts as run too; other events and hand-made heats don't.
|
||||
const sessions = [{ ...ranFinal, status: "ready" }, readyFinal, { ...ranFinal, id: "o", eventId: "other" }, { ...ranFinal, id: "m", generated: false }];
|
||||
assert.deepEqual(getRunGeneratedSessions(sessions, "event_1", "final", state.resultsBySession).map((session) => session.id), ["a1"]);
|
||||
assert.deepEqual(getRunGeneratedSessions([readyFinal], "event_1", "final", {}), []);
|
||||
});
|
||||
Reference in new issue
Block a user