feat(judging): judge finished heats, DSQ/DNF, reasons, own time and driver calls per EFRA (1.70.0)

This commit is contained in:
larssand committed 2026-11-05 23:31:01 +01:00
1 parent 2e3676d0cd
commit be99cfaab2
17 files changed
+399 -25

No files matched your search

+83 -6
View File
@@ -49,6 +49,7 @@ import { createSessionReplayRuntime } from "./session_replay.js";
import { renderTeamStintLog as renderTeamStintLogHelper, renderSessionChannelAnalysis as renderSessionChannelAnalysisHelper, renderTeamRaceStandings as renderTeamRaceStandingsHelper, getSessionSortWeight as getSessionSortWeightHelper, getDriverDisplayById as getDriverDisplayByIdHelper, renderPositionGrid as renderPositionGridHelper, renderGridEditor as renderGridEditorHelper, getFinalMainLayouts as getFinalMainLayoutsHelper, renderFinalMatrix as renderFinalMatrixHelper, buildPrintBrandBlock as buildPrintBrandBlockHelper, buildRaceStartListsHtml as buildRaceStartListsHtmlHelper, buildRaceResultsHtml as buildRaceResultsHtmlHelper, buildTeamRaceResultsHtml as buildTeamRaceResultsHtmlHelper } from "./race_render_helpers.js";
import { setCompetitorRaceStatus as setCompetitorRaceStatusLogic, logRaceControlCall, countOfficialWarnings } from "./judging_logic.js";
import { setCompetitorLapStatus as setCompetitorLapStatusLogic, getManualCorrectionSummary as getManualCorrectionSummaryLogic, applyCompetitorCorrection as applyCompetitorCorrectionLogic, recalculateCompetitorFromPassings as recalculateCompetitorFromPassingsLogic, invalidateCompetitorLastLap as invalidateCompetitorLastLapLogic, restoreCompetitorLastInvalidLap as restoreCompetitorLastInvalidLapLogic, findPassingByUndoMarker as findPassingByUndoMarkerLogic, undoJudgingAdjustment as undoJudgingAdjustmentLogic, getJudgeFilteredRows as getJudgeFilteredRowsLogic, getJudgeFilteredLog as getJudgeFilteredLogLogic } from "./judging_logic.js";
const PRODUCT_NAME = "RC RaceCore";
@@ -803,7 +804,9 @@ const speakerPanelDeps = {
renderSpeakerPanel: () => renderSpeakerPanel({ state, t, escapeHtml }),
bindSpeakerPanel: (root) => bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView }),
};
const renderJudging = () => renderJudgingView({ ...speakerPanelDeps, state, dom, t, escapeHtml, formatLap, renderTable, getActiveSession, ensureSessionResult, buildLeaderboard, getSessionTypeLabel, getJudgeFilteredRows, getJudgeFilteredLog, getCompetitorPassings, isCountedPassing, getPassingValidationLabel, undoJudgingAdjustment, applyCompetitorCorrection, invalidateCompetitorLastLap, restoreCompetitorLastInvalidLap, renderView, getSelectedJudgeKey: () => selectedJudgeKey, setSelectedJudgeKey: (value) => { selectedJudgeKey = value; }, getJudgingCompetitorFilter: () => judgingCompetitorFilter, setJudgingCompetitorFilter: (value) => { judgingCompetitorFilter = value; }, getJudgingLogFilter: () => judgingLogFilter, setJudgingLogFilter: (value) => { judgingLogFilter = value; } , setCompetitorLapStatus });
const renderJudging = () => renderJudgingView({ ...speakerPanelDeps,
getJudgingSession, setJudgingSessionId: (value) => { judgingSessionId = value; }, getJudgingSessionChoices,
setCompetitorRaceStatus, callRaceControl, countOfficialWarnings, hasFinalsFromQualifying, state, dom, t, escapeHtml, formatLap, renderTable, getActiveSession, ensureSessionResult, buildLeaderboard, getSessionTypeLabel, getJudgeFilteredRows, getJudgeFilteredLog, getCompetitorPassings, isCountedPassing, getPassingValidationLabel, undoJudgingAdjustment, applyCompetitorCorrection, invalidateCompetitorLastLap, restoreCompetitorLastInvalidLap, renderView, getSelectedJudgeKey: () => selectedJudgeKey, setSelectedJudgeKey: (value) => { selectedJudgeKey = value; }, getJudgingCompetitorFilter: () => judgingCompetitorFilter, setJudgingCompetitorFilter: (value) => { judgingCompetitorFilter = value; }, getJudgingLogFilter: () => judgingLogFilter, setJudgingLogFilter: (value) => { judgingLogFilter = value; } , setCompetitorLapStatus });
const normalizeTrainingState = (training) => normalizeTrainingStateLogic(training, { uid });
const syncTrainingLedger = () => {
state.training = syncTrainingLedgerLogic(state.training, state, { uid });
@@ -1054,7 +1057,8 @@ const saveCorrectionFor = (session) => () => {
};
const applyCompetitorCorrection = (session, row, options = {}) => {
const result = applyCompetitorCorrectionLogic(session, row, options, { ensureSessionResult, uid, t, formatLap, saveState: saveCorrectionFor(session) });
if (!options.reset && ((Number(options.timeMsDelta || 0) > 0) || (Number(options.lapDelta || 0) < 0))) {
// Called out only while the heat runs - a penalty after the race is just written down.
if (!options.reset && ["running", "paused"].includes(session?.status) && ((Number(options.timeMsDelta || 0) > 0) || (Number(options.lapDelta || 0) < 0))) {
triggerRaceAudio("penalty", { variables: { driverName: row?.displayName || row?.driverName || "" }, driverId: row?.driverId, logData: { raceId: session?.eventId, driverId: row?.driverId } });
}
return result;
@@ -1081,6 +1085,32 @@ const restoreCompetitorLastInvalidLap = (session, row) => restoreCompetitorLastI
const findPassingByUndoMarker = (session, rowKey, passingTimestamp) => findPassingByUndoMarkerLogic(session, rowKey, passingTimestamp, { ensureSessionResult });
const undoJudgingAdjustment = (session, adjustmentId) => undoJudgingAdjustmentLogic(session, adjustmentId, { ensureSessionResult, findPassingByUndoMarker, recalculateCompetitorFromPassings, uid, t, saveState: saveCorrectionFor(session) });
const getJudgeFilteredRows = (rows, filterValue) => getJudgeFilteredRowsLogic(rows, filterValue);
// Judging: DSQ / DNF, race-control calls to one driver, and which heat is judged.
const setCompetitorRaceStatus = (session, row, status, options = {}) => {
const changed = setCompetitorRaceStatusLogic(session, row, status, options, { ensureSessionResult, uid, t, saveState: saveCorrectionFor(session) });
if (changed && status === "dsq" && ["running", "paused"].includes(session?.status)) {
triggerRaceAudio("disqualified", { force: true, interrupt: true, variables: { driverName: row?.displayName || row?.driverName || "" }, driverId: row?.driverId, logData: { raceId: session?.eventId, driverId: row?.driverId } });
}
return changed;
};
const RACE_CALL_AUDIO = { attention: "driver_attention", official_warning: "official_warning", stop_and_go: "stop_and_go", drive_through: "drive_through" };
const callRaceControl = (session, row, kind, options = {}) => {
const entry = logRaceControlCall(session, row, kind, options, { ensureSessionResult, uid, t, saveState: saveCorrectionFor(session) });
if (entry) triggerRaceAudio(RACE_CALL_AUDIO[kind], { force: true, interrupt: true, variables: { driverName: row?.displayName || row?.driverName || "" }, driverId: row?.driverId, logData: { raceId: session?.eventId, sessionId: session?.id, driverId: row?.driverId } });
return entry;
};
const getJudgingSession = () => (judgingSessionId && state.sessions.find((session) => session.id === judgingSessionId)) || null;
// The heats to judge: the live / active one first, then every run heat, newest first.
const getJudgingSessionChoices = () => {
const active = getActiveSession();
const run = state.sessions
.filter((session) => session.id !== active?.id && session.status !== "ready")
.sort((a, b) => Number(b.startedAt || b.endedAt || 0) - Number(a.startedAt || a.endedAt || 0))
.slice(0, 60);
const label = (session) => `${["running", "paused"].includes(session.status) ? "● " : ""}${getEventName(session.eventId) || "-"} – ${session.name} (${getStatusLabel(session.status)})`;
return [...(active ? [active] : []), ...run].map((session) => ({ id: session.id, label: label(session) }));
};
const hasFinalsFromQualifying = (session) => state.sessions.some((item) => item.eventId === session.eventId && item.type === "final");
const getJudgeFilteredLog = (adjustments, filterValue) => getJudgeFilteredLogLogic(adjustments, filterValue);
const NAV_ITEMS = [
@@ -2496,6 +2526,29 @@ const TRANSLATIONS = {
"timing.invalid_long": "Över maxvarv",
"timing.long_lap_stint": "Långt varv · räknat · ny stint",
"judging.title": "Domarvy",
"judging.session_pick": "Heat att döma",
"judging.after_race_hint": "heatet är klart – straff och DSQ räknas om i resultat och ställning",
"judging.finals_exist_hint": "Finalerna är redan skapade från kvalet. Ändras ordningen: skapa om finalerna under Hantera.",
"judging.custom_sec": "Egen tid (s)",
"judging.custom_sec_apply": "+ s straff",
"judging.reason": "Orsak (loggas)",
"judging.reason_placeholder": "T.ex. ojust omkörning, ej godkänd bil, tjuvstart",
"judging.dsq": "DSQ – diskvalificera",
"judging.dnf": "DNF",
"judging.status_clear": "Ta bort DSQ/DNF",
"judging.status_dsq": "Diskvalificerad (DSQ)",
"judging.status_dnf": "Bröt (DNF)",
"judging.status_cleared": "DSQ/DNF borttaget",
"judging.dsq_confirm": "Diskvalificera {name} i det här heatet? Placeras sist (i kval: poäng som sista plats, enligt EFRA).",
"judging.calls_title": "Utrop till föraren",
"judging.calls_hint": "Speakern ropar upp föraren och det loggas. Ett stop & go räknas inte automatiskt – körs det inte: ge tidsstraff (EFRA: 10 s).",
"judging.call_attention": "Observera (blå flagg)",
"judging.call_official_warning": "Officiell varning",
"judging.call_stop_and_go": "Stop & go",
"judging.call_drive_through": "Drive through (extra depåstopp)",
"judging.two_warnings_confirm": "{name} har nu två officiella varningar. Enligt EFRA blir föraren diskvalificerad från heatet. Diskvalificera?",
"judging.two_warnings_reason": "Två officiella varningar",
"judging.filter_log_calls": "Utrop",
"judging.active_session": "Aktiv session",
"judging.no_active_session": "Ingen aktiv session vald.",
"judging.select_competitor": "Välj förare eller lag",
@@ -2999,9 +3052,9 @@ const TRANSLATIONS = {
"guide.validation_2": "Ogiltiga kortvarv under min-gränsen räknas inte alls i leaderboard eller statistik.",
"guide.validation_3": "Ogiltiga långvarv över max-gränsen räknas inte som varv, men de kan bryta lap-basen så nästa giltiga varv börjar om korrekt.",
"guide.validation_4": "När ordinarie tid är slut kan sessionen gå in i Follow-up aktiv om du har satt Follow-up tid i raceformat eller sessionen.",
"guide.validation_5": "Straff (+1/-1 varv, +1/+5/-1 sekunder) finns bara i race (kval, heat, final) och görs av domaren i Domarvyn. Det slår igenom direkt i leaderboarden. Tidtagning -> Detaljer visar korrigeringarna och har knappen Öppna i Domarvyn.",
"guide.validation_5": "Straff (+1/-1 varv, +1/+5/-1 s, egen tid t.ex. +10 s), DSQ och DNF finns i race (kval, heat, final) och ges i Domarvyn – även efter att heatet är klart (protest, ej godkänd bil): välj heatet under Heat att döma. Skriv en orsak, den loggas. DSQ placerar föraren sist; i kval ger det poäng som sista plats (EFRA). Resultat, ställning, race-översikt och arkiv räknas om direkt. Är finalerna redan skapade från kvalet varnar Domarvyn – skapa om dem om ordningen ändrats.",
"guide.validation_6": "Under träning tar du bort, återställer eller godkänner valfritt varv direkt i Tidtagning -> Detaljer. Misstänkt korta varv (genvägar) flaggas med ⚠ och listas med Godkänn / Ta bort på Tidtagning och Race Day.",
"guide.validation_7": "Domarvyn har leaderboard, varvhistorik med Ta bort / Återställ per varv, straff (endast race) och domarlogg med ångra för pågående session.",
"guide.validation_7": "Under racet: Utrop till föraren – Observera (blå flagg), Officiell varning, Stop & go och Drive through (extra depåstopp). Speakern ropar upp föraren och det loggas med orsak. Två officiella varningar = DSQ från heatet (EFRA), Domarvyn frågar. Ett stop & go räknas inte automatiskt; körs det inte, ge tidsstraff (EFRA: 10 s). Domarvyn har också varvhistorik med Ta bort / Återställ per varv och domarlogg (filter Utrop) med ångra.",
"guide.validation_8": "Domarvyn kan filtrera på ogiltiga rader, korrigerade rader eller teamrace, exportera domarloggen och ångra flera senaste manuella åtgärder via undo-knappar.",
"guide.qualifying_title": "Seedning, poängtabeller och tie-break",
"guide.qualifying_1": "Practice och kval kan nu använda tre seedmetoder: bästa N varv som summa, bästa N varv som snitt eller bästa N konsekutiva varv.",
@@ -4592,6 +4645,29 @@ const TRANSLATIONS = {
"timing.invalid_long": "Over max lap",
"timing.long_lap_stint": "Long lap · counted · new stint",
"judging.title": "Judging view",
"judging.session_pick": "Heat to judge",
"judging.after_race_hint": "the heat is finished – penalties and DSQ update the results and standings",
"judging.finals_exist_hint": "The finals were already made from qualifying. If the order changes: make the finals again under Manage.",
"judging.custom_sec": "Own time (s)",
"judging.custom_sec_apply": "+ s penalty",
"judging.reason": "Reason (logged)",
"judging.reason_placeholder": "E.g. unfair overtake, car not legal, jump start",
"judging.dsq": "DSQ – disqualify",
"judging.dnf": "DNF",
"judging.status_clear": "Remove DSQ/DNF",
"judging.status_dsq": "Disqualified (DSQ)",
"judging.status_dnf": "Did not finish (DNF)",
"judging.status_cleared": "DSQ/DNF removed",
"judging.dsq_confirm": "Disqualify {name} in this heat? Classified last (in qualifying: last-place points, as in EFRA).",
"judging.calls_title": "Calls to the driver",
"judging.calls_hint": "The speaker calls the driver and it is logged. A stop & go is not timed - if it is not served, give a time penalty (EFRA: 10 s).",
"judging.call_attention": "Attention (blue flag)",
"judging.call_official_warning": "Official warning",
"judging.call_stop_and_go": "Stop & go",
"judging.call_drive_through": "Drive through (extra pit stop)",
"judging.two_warnings_confirm": "{name} now has two official warnings. Under EFRA the driver is disqualified from the heat. Disqualify?",
"judging.two_warnings_reason": "Two official warnings",
"judging.filter_log_calls": "Calls",
"judging.active_session": "Active session",
"judging.no_active_session": "No active session selected.",
"judging.select_competitor": "Select driver or team",
@@ -5095,9 +5171,9 @@ const TRANSLATIONS = {
"guide.validation_2": "Invalid short laps under the minimum threshold do not count in the leaderboard or statistics.",
"guide.validation_3": "Invalid long laps over the maximum threshold do not count as laps, but they can reset the lap base so the next valid lap starts correctly.",
"guide.validation_4": "When the scheduled time ends, the session can enter Follow-up active if Follow-up time has been configured in race format or on the session.",
"guide.validation_5": "Penalties (+1/-1 lap, +1/+5/-1 seconds) exist only in races (qualifying, heats, finals) and are given by the judge in the Judging view. The leaderboard updates immediately. Timing -> Details shows the corrections and has an Open in Judging button.",
"guide.validation_5": "Penalties (+1/-1 lap, +1/+5/-1 s, own time e.g. +10 s), DSQ and DNF exist in races (qualifying, heats, finals) and are given in the Judging view - also after the heat is finished (a protest, a car not legal): pick the heat under Heat to judge. Write a reason; it is logged. DSQ classifies the driver last; in qualifying it scores last-place points (EFRA). Results, standings, race overview and archive update at once. If the finals were already made from qualifying, Judging warns - make them again if the order changed.",
"guide.validation_6": "In practice, remove, restore or approve any lap right in Timing -> Details. Suspiciously short laps (shortcuts) are flagged with ⚠ and listed with Approve / Remove on Timing and Race Day.",
"guide.validation_7": "The Judging view has the leaderboard, lap history with Remove / Restore per lap, penalties (races only) and the judging log with undo for the current session.",
"guide.validation_7": "During the race: Calls to the driver - Attention (blue flag), Official warning, Stop & go and Drive through (extra pit stop). The speaker calls the driver and it is logged with the reason. Two official warnings = DSQ from the heat (EFRA); Judging asks. A stop & go is not timed; if it is not served, give a time penalty (EFRA: 10 s). Judging also has the lap history with Remove / Restore per lap and the judging log (filter Calls) with undo.",
"guide.validation_8": "The Judging view can filter invalid rows, corrected rows or team race rows, export the judging log and undo multiple recent manual actions via undo buttons.",
"guide.qualifying_title": "Seeding, points tables and tie-break",
"guide.qualifying_1": "Practice and qualifying can now use three seed methods: best N laps as total, best N laps as average or best N consecutive laps.",
@@ -5342,6 +5418,7 @@ let selectedEventEditId = null;
let selectedSessionEditId = null;
let selectedTeamEditId = null;
let selectedJudgeKey = null;
let judgingSessionId = "";
let selectedTrainingDriverId = String(urlParams.get("driver") || "");
let selectedTrainingClassId = String(urlParams.get("class") || "");
let judgingCompetitorFilter = "all";
+68 -1
View File
@@ -58,7 +58,8 @@ export function applyCompetitorCorrection(session, row, options = {}, { ensureSe
competitorKey: row.key,
displayName: row.displayName || row.driverName || t("common.unknown_driver"),
action: t("timing.manual_corrections"),
detail: detailBits.join(" • ") || "-",
detail: [detailBits.join(" • "), String(options.reason || "").trim()].filter(Boolean).join(" – ") || "-",
reason: String(options.reason || "").trim(),
category: "correction",
undo: {
type: "restore_correction_state",
@@ -212,6 +213,11 @@ export function undoJudgingAdjustment(session, adjustmentId, { ensureSessionResu
// both and the newer one silently re-adding one back. See applyCompetitorCorrection.
entry.manualLapAdjustment = (Number(entry.manualLapAdjustment || 0) || 0) - (Number(adjustment.undo.lapDelta || 0) || 0);
entry.manualTimeAdjustmentMs = (Number(entry.manualTimeAdjustmentMs || 0) || 0) - (Number(adjustment.undo.timeMsDelta || 0) || 0);
} else if (adjustment.undo.type === "set_race_status") {
entry.raceStatus = adjustment.undo.raceStatus || "";
if (!entry.raceStatus) delete entry.raceStatus;
} else if (adjustment.undo.type === "race_call") {
// A spoken call can't be taken back; undo only takes it out of the count (warnings).
} else if (adjustment.undo.type === "set_passing_validity") {
const passing = findPassingByUndoMarker(session, adjustment.competitorKey, adjustment.undo.passingTimestamp);
if (!passing) {
@@ -266,8 +272,69 @@ export function getJudgeFilteredLog(adjustments, filterValue) {
if (filterValue === "invalid") {
return adjustments.filter((entry) => entry.category === "invalid");
}
if (filterValue === "calls") {
return adjustments.filter((entry) => entry.category === "call");
}
if (filterValue === "undo") {
return adjustments.filter((entry) => entry.category === "undo");
}
return adjustments;
}
// DSQ / DNF for a driver in a heat, qualifier or final - also after it is finished (a protest,
// a car found illegal). EFRA: a driver disqualified in a qualifying round scores points for
// last place in it (as with no time); disqualified from a heat or final = classified last.
// DNF keeps the laps (classified on laps as usual) and is shown as DNF. "" clears it.
export function setCompetitorRaceStatus(session, row, status, { reason = "" } = {}, { ensureSessionResult, uid, t, saveState }) {
const result = ensureSessionResult(session.id);
const entry = result.competitors[row.key];
if (!entry || !["dsq", "dnf", ""].includes(status)) return false;
const previous = entry.raceStatus || "";
if (previous === status) return false;
if (status) entry.raceStatus = status; else delete entry.raceStatus;
const cleanReason = String(reason || "").trim();
result.adjustments.push({
id: uid("judge"),
ts: Date.now(),
competitorKey: row.key,
displayName: row.displayName || row.driverName || t("common.unknown_driver"),
action: status ? t(`judging.status_${status}`) : t("judging.status_cleared"),
detail: cleanReason || "-",
reason: cleanReason,
category: "correction",
undo: { type: "set_race_status", raceStatus: previous },
});
saveState();
return true;
}
// A race-control call to one driver, logged with the reason: "attention" (blue flag),
// "official_warning", "stop_and_go", "drive_through". The stop itself isn't timed - if it is
// not served, the judge gives a time penalty (EFRA: 10 s when the driver can't be called in).
export const RACE_CALLS = ["attention", "official_warning", "stop_and_go", "drive_through"];
export function logRaceControlCall(session, row, kind, { reason = "" } = {}, { ensureSessionResult, uid, t, saveState }) {
const result = ensureSessionResult(session.id);
if (!result.competitors[row.key] || !RACE_CALLS.includes(kind)) return null;
const cleanReason = String(reason || "").trim();
const entry = {
id: uid("judge"),
ts: Date.now(),
competitorKey: row.key,
displayName: row.displayName || row.driverName || t("common.unknown_driver"),
action: t(`judging.call_${kind}`),
detail: cleanReason || "-",
reason: cleanReason,
callKind: kind,
category: "call",
undo: { type: "race_call" },
};
result.adjustments.push(entry);
saveState();
return entry;
}
// Official warnings given to a driver in this session (undone ones don't count).
export function countOfficialWarnings(result, competitorKey) {
return (result?.adjustments || []).filter((entry) => entry.competitorKey === competitorKey && entry.callKind === "official_warning" && !entry.undoneAt).length;
}
+2
View File
@@ -38,6 +38,8 @@ export const RACE_AUDIO_EVENT_DEFINITIONS = Object.freeze([
event("marshal_warning", "control", "high", true, "effects/warning.wav", 1000), event("marshal_required", "control", "high", true, "effects/warning.wav", 1000),
event("penalty", "control", "high", true, "effects/warning.wav", 750), event("stop_and_go", "control", "high", true, "effects/warning.wav"),
event("drive_through", "control", "high", true, "effects/warning.wav"), event("disqualified", "control", "high", true, "effects/warning.wav"),
// EFRA 9.1-9.3: "Attention driver (name)" (blue flag) and an official warning (2 = DSQ).
event("driver_attention", "control", "high", true, "effects/warning.wav", 750), event("official_warning", "control", "high", true, "effects/warning.wav"),
event("pit_lane_open", "pit", "normal"), event("pit_lane_closed", "pit", "normal"),
event("entering_pits", "pit", "low", false, "effects/transponder_pass.wav"), event("leaving_pits", "pit", "low", false, "effects/transponder_pass.wav"),
event("pit_speed_warning", "pit", "high", true, "effects/warning.wav"),
+7
View File
@@ -4872,3 +4872,10 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
.manual-session-add > summary { font-weight: 600; padding: 4px 0; }
.manual-session-add[open] > summary { margin-bottom: 12px; }
.manage-branding > summary h3 { display: inline; }
/* Judging: heat picker, own penalty time, reason */
.judging-session-pick { display: grid; gap: 4px; max-width: 520px; }
.judge-custom-sec { display: inline-flex; gap: 6px; align-items: center; }
.judge-custom-sec input { width: 80px; }
.judge-reason { display: grid; gap: 4px; }
.pill-red { background: var(--danger, #c0392b); color: #fff; }
+22 -5
View File
@@ -343,7 +343,21 @@ export function buildLeaderboard(session, { ensureSessionResult, getSessionTarge
};
});
// Judge's DSQ / DNF (judging_logic setCompetitorRaceStatus): DSQ always last, its time out of
// every comparison; DNF is classified on its laps as usual and only labelled.
rows.forEach((row) => {
if (row.raceStatus === "dsq") {
row.comparisonMs = Number.MAX_SAFE_INTEGER;
row.seedMetric = null;
row.practiceMetric = null;
row.resultDisplay = "DSQ";
} else if (row.raceStatus === "dnf") {
row.resultDisplay = `DNF · ${row.resultDisplay}`;
}
});
rows.sort((a, b) => {
const aDsq = a.raceStatus === "dsq";
if (aDsq !== (b.raceStatus === "dsq")) return aDsq ? 1 : -1;
if (isRollingPractice) {
if (a.comparisonMs !== b.comparisonMs) {
return a.comparisonMs - b.comparisonMs;
@@ -721,6 +735,8 @@ export function buildQualifyingStandings(event, { getSessionsForEvent, buildLead
: rows;
rowsWithDns.forEach((row, index) => {
const key = row.driverId || row.key;
// EFRA: a time disqualified in a round scores points for last place in that round.
const place = row.raceStatus === "dsq" ? entrantCount : index + 1;
if (!competitorMap.has(key)) {
competitorMap.set(key, {
key,
@@ -733,10 +749,10 @@ export function buildQualifyingStandings(event, { getSessionsForEvent, buildLead
});
}
const entry = competitorMap.get(key);
entry.points.push(getQualifyingPointsValue(index + 1, entrantCount, pointsTable));
entry.ranks.push(index + 1);
entry.points.push(getQualifyingPointsValue(place, entrantCount, pointsTable));
entry.ranks.push(place);
entry.roundMetrics.push(row.comparisonMs);
if (Number.isFinite(row.bestLapMs)) {
if (Number.isFinite(row.bestLapMs) && row.raceStatus !== "dsq") {
entry.bestLaps.push(row.bestLapMs);
}
if (!entry.bestRoundDisplay || row.comparisonMs < (entry.bestRoundMetricValue ?? Number.MAX_SAFE_INTEGER)) {
@@ -1085,8 +1101,9 @@ export function buildFinalStandings(event, { getSessionsForEvent, buildLeaderboa
});
}
const entry = competitorMap.get(key);
entry.legRanks.push(index + 1);
entry.bestElapsedMs.push(row.totalElapsedMs);
// Disqualified from a final = classified last in it (behind those who did not start).
entry.legRanks.push(row.raceStatus === "dsq" ? rowsWithDns.length + 1 : index + 1);
entry.bestElapsedMs.push(row.raceStatus === "dsq" ? Number.MAX_SAFE_INTEGER : row.totalElapsedMs);
});
});
+74 -5
View File
@@ -739,18 +739,28 @@ export function renderJudgingView(deps) {
getJudgingCompetitorFilter, setJudgingCompetitorFilter, getJudgingLogFilter, setJudgingLogFilter,
setCompetitorLapStatus = () => false,
renderSpeakerPanel = () => "", bindSpeakerPanel = () => {},
// The heat being judged: the active one, or one picked (also a finished one - protests).
getJudgingSession = () => null, setJudgingSessionId = () => {}, getJudgingSessionChoices = () => [],
setCompetitorRaceStatus = () => false, callRaceControl = () => null, countOfficialWarnings = () => 0,
hasFinalsFromQualifying = () => false,
} = deps;
const active = getActiveSession();
const active = getJudgingSession() || getActiveSession();
if (!active) {
dom.view.innerHTML = `
<section class="panel">
<div class="panel-header"><h3>${t("judging.title")}</h3></div>
<div class="panel-body"><p>${t("judging.no_active_session")}</p></div>
<div class="panel-body"><p>${t("judging.no_active_session")}</p>
${getJudgingSessionChoices().length ? `<label class="judging-session-pick"><span>${t("judging.session_pick")}</span><select id="judgingSessionSelect"><option value="">-</option>${getJudgingSessionChoices().map((choice) => `<option value="${escapeHtml(choice.id)}">${escapeHtml(choice.label)}</option>`).join("")}</select></label>` : ""}
</div>
</section>
${renderSpeakerPanel()}
`;
bindSpeakerPanel(dom.view);
document.getElementById("judgingSessionSelect")?.addEventListener("change", (changeEvent) => {
setJudgingSessionId(changeEvent.currentTarget.value);
renderJudgingView(deps);
});
return;
}
@@ -773,10 +783,14 @@ export function renderJudgingView(deps) {
<section class="panel">
<div class="panel-header">
<h3>${t("judging.title")}</h3>
<span class="pill pill-green">${escapeHtml(active.name)}</span>
<span class="pill ${["running", "paused"].includes(active.status) ? "pill-green" : ""}">${escapeHtml(active.name)}</span>
</div>
<div class="panel-body">
<p>${t("judging.active_session")}: <strong>${escapeHtml(active.name)}</strong> • ${escapeHtml(getSessionTypeLabel(active.type))}</p>
<label class="judging-session-pick"><span>${t("judging.session_pick")}</span>
<select id="judgingSessionSelect">${getJudgingSessionChoices().map((choice) => `<option value="${escapeHtml(choice.id)}" ${choice.id === active.id ? "selected" : ""}>${escapeHtml(choice.label)}</option>`).join("")}</select>
</label>
<p>${escapeHtml(getSessionTypeLabel(active.type))}${["finished", "stopped"].includes(active.status) ? ` • ${t("judging.after_race_hint")}` : ""}</p>
${active.type === "qualification" && hasFinalsFromQualifying(active) ? `<p class="form-error">${t("judging.finals_exist_hint")}</p>` : ""}
</div>
</section>
@@ -828,11 +842,29 @@ export function renderJudgingView(deps) {
<button class="btn" id="judgeLapMinus">${t("timing.penalty_remove_lap")}</button>
<button class="btn" id="judgeSecPlus">${t("timing.penalty_add_sec")}</button>
<button class="btn" id="judgeFivePlus">${t("timing.penalty_add_5sec")}</button>
<button class="btn" id="judgeSecMinus">${t("timing.penalty_remove_sec")}</button>`}
<button class="btn" id="judgeSecMinus">${t("timing.penalty_remove_sec")}</button>
<span class="judge-custom-sec"><input type="number" id="judgeCustomSec" min="1" max="600" step="1" value="10" aria-label="${escapeHtml(t("judging.custom_sec"))}" /><button class="btn" id="judgeCustomApply" type="button">${t("judging.custom_sec_apply")}</button></span>`}
<button class="btn" id="judgeInvalidate">${t("timing.invalidate_last_lap")}</button>
<button class="btn" id="judgeRestore">${t("timing.restore_last_invalid")}</button>
${isPracticeType(active.type) ? "" : `<button class="btn btn-danger" id="judgeReset">${t("timing.penalty_reset")}</button>`}
</div>
${isPracticeType(active.type) ? "" : `
<label class="mt-8 judge-reason"><span>${t("judging.reason")}</span><input id="judgeReason" type="text" maxlength="120" placeholder="${escapeHtml(t("judging.reason_placeholder"))}" /></label>
<div class="actions mt-8">
${selectedRow.raceStatus === "dsq" ? `<span class="pill pill-red">DSQ</span>` : selectedRow.raceStatus === "dnf" ? `<span class="pill">DNF</span>` : ""}
${selectedRow.raceStatus !== "dsq" ? `<button class="btn btn-danger" id="judgeDsq" type="button">${t("judging.dsq")}</button>` : ""}
${selectedRow.raceStatus !== "dnf" ? `<button class="btn" id="judgeDnf" type="button">${t("judging.dnf")}</button>` : ""}
${selectedRow.raceStatus ? `<button class="btn" id="judgeStatusClear" type="button">${t("judging.status_clear")}</button>` : ""}
</div>
${["running", "paused"].includes(active.status) ? `
<h4 class="mt-16">${t("judging.calls_title")}</h4>
<p class="hint">${t("judging.calls_hint")}</p>
<div class="actions">
<button class="btn" type="button" data-judge-call="attention">${t("judging.call_attention")}</button>
<button class="btn" type="button" data-judge-call="official_warning">${t("judging.call_official_warning")} (${countOfficialWarnings(result, selectedRow.key)})</button>
<button class="btn btn-danger" type="button" data-judge-call="stop_and_go">${t("judging.call_stop_and_go")}</button>
<button class="btn btn-danger" type="button" data-judge-call="drive_through">${t("judging.call_drive_through")}</button>
</div>` : ""}`}
<div class="mt-16">
<h4>${t("timing.lap_history")}</h4>
${
@@ -868,6 +900,7 @@ export function renderJudgingView(deps) {
<option value="all" ${getJudgingLogFilter() === "all" ? "selected" : ""}>${t("judging.filter_all")}</option>
<option value="corrections" ${getJudgingLogFilter() === "corrections" ? "selected" : ""}>${t("judging.filter_log_corrections")}</option>
<option value="invalid" ${getJudgingLogFilter() === "invalid" ? "selected" : ""}>${t("judging.filter_log_invalidations")}</option>
<option value="calls" ${getJudgingLogFilter() === "calls" ? "selected" : ""}>${t("judging.filter_log_calls")}</option>
<option value="undo" ${getJudgingLogFilter() === "undo" ? "selected" : ""}>${t("judging.filter_log_undo")}</option>
</select>
<button class="btn" id="judgingExportLog" type="button">${t("judging.export_log")}</button>
@@ -960,9 +993,45 @@ export function renderJudgingView(deps) {
});
});
document.getElementById("judgingSessionSelect")?.addEventListener("change", (changeEvent) => {
setJudgingSessionId(changeEvent.currentTarget.value);
setSelectedJudgeKey(null);
renderJudgingView(deps);
});
if (!selectedRow) {
return;
}
const reason = () => String(document.getElementById("judgeReason")?.value || "").trim();
document.getElementById("judgeCustomApply")?.addEventListener("click", () => {
const seconds = Math.round(Number(document.getElementById("judgeCustomSec")?.value || 0));
if (!(seconds > 0)) return;
applyCompetitorCorrection(active, selectedRow, { timeMsDelta: seconds * 1000, reason: reason() });
renderJudgingView(deps);
});
document.getElementById("judgeDsq")?.addEventListener("click", () => {
if (!window.confirm(t("judging.dsq_confirm", { name: selectedRow.displayName || selectedRow.driverName || "" }))) return;
setCompetitorRaceStatus(active, selectedRow, "dsq", { reason: reason() });
renderJudgingView(deps);
});
document.getElementById("judgeDnf")?.addEventListener("click", () => {
setCompetitorRaceStatus(active, selectedRow, "dnf", { reason: reason() });
renderJudgingView(deps);
});
document.getElementById("judgeStatusClear")?.addEventListener("click", () => {
setCompetitorRaceStatus(active, selectedRow, "", { reason: reason() });
renderJudgingView(deps);
});
document.querySelectorAll("[data-judge-call]").forEach((button) => button.addEventListener("click", () => {
const kind = button.dataset.judgeCall;
callRaceControl(active, selectedRow, kind, { reason: reason() });
// EFRA 9.3: two official warnings - disqualified from the race in progress.
if (kind === "official_warning" && countOfficialWarnings(ensureSessionResult(active.id), selectedRow.key) >= 2
&& window.confirm(t("judging.two_warnings_confirm", { name: selectedRow.displayName || selectedRow.driverName || "" }))) {
setCompetitorRaceStatus(active, selectedRow, "dsq", { reason: t("judging.two_warnings_reason") });
}
renderJudgingView(deps);
}));
document.getElementById("judgeLapPlus")?.addEventListener("click", () => {
applyCompetitorCorrection(active, selectedRow, { lapDelta: 1 });