feat(race-day): live race for the race controller with order, laps, gaps and estimated finish (1.47.0)

This commit is contained in:
larssand committed 2026-11-01 16:38:08 +01:00
1 parent c4163441fc
commit 54487a18a6
12 files changed
+169 -7

No files matched your search

+13
View File
@@ -1033,3 +1033,16 @@ export function buildFinalStandings(event, { getSessionsForEvent, buildLeaderboa
return a.orderingIndex - b.orderingIndex;
});
}
// Where a car ends when its time is up, at its recent pace (its last two laps, else its
// average): the laps it will have and the time of its last crossing. Once over time, the car
// takes the flag on its next crossing. null for untimed sessions or before the first lap.
export function estimateFinish(row, targetMs) {
const laps = Number(row?.laps || 0);
const elapsedMs = Number(row?.totalElapsedMs || 0);
if (!targetMs || laps < 1 || elapsedMs <= 0) return null;
const recent = [row.lastLapMs, row.previousLapMs].map(Number).filter((value) => value > 0);
const paceMs = recent.length ? recent.reduce((sum, value) => sum + value, 0) / recent.length : elapsedMs / laps;
const moreLaps = elapsedMs >= targetMs ? 0 : Math.ceil((targetMs - elapsedMs) / paceMs);
return { laps: laps + moreLaps, timeMs: Math.round(elapsedMs + moreLaps * paceMs), paceMs: Math.round(paceMs) };
}