feat(practice): flag suspiciously short laps and remove any lap in one click
Practice laps under 85% of the driver's own median (a likely shortcut) are flagged: counted, but never a best lap, record or training stat until approved. Timing and Race Day get a one-click Approve/Remove panel, overlays show a warning mark, and any lap can be removed or restored from Timing and Judging with undo. Also sends judge corrections straight to the server so its hot-results protection can no longer hold back a correction made right after a passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3cc4fa0845
commit
8601954ea2
24 files changed
+556
-60
No files matched your search
+12
-4
@@ -1,6 +1,7 @@
|
||||
import { decoderDiagnostics } from "./decoder_diagnostics.js";
|
||||
import { getControlledLapStreak } from "./training_logic.js";
|
||||
import { usesPersonalClock, getLatestClockStartTs } from "./prologue_logic.js";
|
||||
import { isSuspectLap, getSuspectReferenceLaps } from "./suspect_laps_logic.js";
|
||||
|
||||
const PRACTICE_SESSION_TYPES = new Set(["open_practice", "free_practice", "practice"]);
|
||||
|
||||
@@ -513,6 +514,12 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
|
||||
const layoutId = String(session.trackLayoutId || "");
|
||||
if (entry.bestLapLayoutId === undefined) entry.bestLapLayoutId = layoutId;
|
||||
else if (entry.bestLapLayoutId !== layoutId) { entry.bestLapMs = null; entry.bestLapLayoutId = layoutId; }
|
||||
// Practice only: a lap far quicker than this driver's own pace (a shortcut) counts as a lap
|
||||
// but not as a best lap, record or training stat until approved (suspect_laps_logic.js).
|
||||
const suspect = PRACTICE_SESSION_TYPES.has(String(session.type || "").toLowerCase())
|
||||
&& !validationWarning
|
||||
&& isSuspectLap(lapMs, getSuspectReferenceLaps(result.passings, key, layoutId));
|
||||
if (suspect) passing.suspect = true;
|
||||
const previousPersonalBest = Number(entry.bestLapMs || 0) || null;
|
||||
const leaderboardBefore = buildLeaderboard(session);
|
||||
const previousPosition = leaderboardBefore.findIndex((row) => row.key === key);
|
||||
@@ -524,7 +531,7 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
|
||||
entry.lastLapMs = lapMs;
|
||||
entry.lastTimestamp = timestamp;
|
||||
|
||||
if (lapMs > 500 && (!entry.bestLapMs || lapMs < entry.bestLapMs)) {
|
||||
if (lapMs > 500 && !suspect && (!entry.bestLapMs || lapMs < entry.bestLapMs)) {
|
||||
entry.bestLapMs = lapMs;
|
||||
}
|
||||
|
||||
@@ -547,9 +554,10 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (previousPersonalBest && lapMs < previousPersonalBest) triggerRaceAudio("personal_best", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (previousSessionFastest && lapMs < previousSessionFastest) triggerRaceAudio("fastest_lap", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (previousTrackRecord && lapMs < previousTrackRecord) triggerRaceAudio("track_record", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (suspect) pushOverlayEvent("suspect", `${entry.displayName || entry.driverName} • ${formatLap(lapMs)} ⚠`);
|
||||
if (!suspect && previousPersonalBest && lapMs < previousPersonalBest) triggerRaceAudio("personal_best", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (!suspect && previousSessionFastest && lapMs < previousSessionFastest) triggerRaceAudio("fastest_lap", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (!suspect && previousTrackRecord && lapMs < previousTrackRecord) triggerRaceAudio("track_record", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
|
||||
if (previousPosition >= 0 && currentPosition >= 0 && currentPosition < previousPosition) triggerRaceAudio("position_gain", { driverId: entry.driverId, competitorKey: key });
|
||||
if (previousPosition >= 0 && currentPosition > previousPosition) triggerRaceAudio("position_loss", { driverId: entry.driverId, competitorKey: key });
|
||||
const leader = leaderboard[0];
|
||||
|
||||
Reference in new issue
Block a user