fix(practice): stop flagging a driver's faster pace as suspect laps (1.42.5)

Flagged laps never entered the reference pace, so a driver who got
faster had every lap flagged. They now count in the reference (last 10
laps), settled flags are released, and a flagged lap counts until it is
removed; Approve only drops the flag.
This commit is contained in:
larssand committed 2026-10-25 21:20:17 +01:00
1 parent 35eb3eb059
commit 2c2b16537e
13 files changed
+132 -47

No files matched your search

+9 -4
View File
@@ -1,7 +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";
import { isSuspectLap, getSuspectReferenceLaps, releaseSettledSuspectLaps } from "./suspect_laps_logic.js";
import { shouldCallPracticePersonalBest } from "./practice_callouts_logic.js";
import { normalizeRaceAudioSettings } from "./race_audio.js";
import { decoderClockCheck, describeDecoderClockSkew } from "./decoder_clock_check.js";
@@ -535,8 +535,8 @@ 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).
// Practice only: a lap far quicker than this driver's own pace (maybe a shortcut) is flagged
// for a look. It counts like any other lap until someone removes it (suspect_laps_logic.js).
const suspect = PRACTICE_SESSION_TYPES.has(String(session.type || "").toLowerCase())
&& !validationWarning
&& isSuspectLap(lapMs, getSuspectReferenceLaps(result.passings, key, layoutId));
@@ -552,11 +552,16 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
entry.lastLapMs = lapMs;
entry.lastTimestamp = timestamp;
if (lapMs > 500 && !suspect && (!entry.bestLapMs || lapMs < entry.bestLapMs)) {
// A suspect lap counts like any other lap until someone removes it; it is only not called
// out as a personal best or record below.
if (lapMs > 500 && (!entry.bestLapMs || lapMs < entry.bestLapMs)) {
entry.bestLapMs = lapMs;
}
result.passings.push(passing);
// Earlier flagged laps of this driver that match the pace now were the driver getting
// faster, not shortcuts: drop their flag so the list only shows what stands out.
if (PRACTICE_SESSION_TYPES.has(String(session.type || "").toLowerCase())) releaseSettledSuspectLaps(result.passings, key, layoutId);
persistPassingToBackend(session.id, passing);
pushOverlayEvent("passing", `${entry.displayName || entry.driverName} • ${formatLap(entry.lastLapMs)}`);
const leaderboard = buildLeaderboard(session);