fix(archive): name the winner from the session result, not the raw lap count (1.47.1)

This commit is contained in:
larssand committed 2026-11-01 19:03:25 +01:00
1 parent 54487a18a6
commit 6142bceca9
5 files changed
+29 -8

No files matched your search

+5 -5
View File
@@ -1,15 +1,15 @@
import { sortableTable, sortValuesAttribute } from "./list_sorting.js";
function buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel }) {
export function buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel, buildLeaderboard }) {
return (state.sessions || [])
.filter((session) => session.status === "finished")
.map((session) => {
const event = state.events.find((item) => item.id === session.eventId) || null;
const result = state.resultsBySession?.[session.id] || null;
const competitors = result ? Object.values(result.competitors || {}) : [];
const winner = competitors
.slice()
.sort((left, right) => (Number(right.laps || 0) - Number(left.laps || 0)) || (Number(left.totalElapsedMs || 0) - Number(right.totalElapsedMs || 0)))[0] || null;
// The same order as the session's result (laps, then time, penalties, seeding). The raw
// laps alone named whoever crossed the line first when laps were equal.
const winner = result ? buildLeaderboard(session)[0] || null : null;
return {
session,
event,
@@ -121,7 +121,7 @@ export function renderResultsArchiveView(deps) {
} = deps;
const filters = getArchiveFilters();
const allRows = buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel });
const allRows = buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel, buildLeaderboard });
const filteredRows = allRows.filter((row) => matchesArchiveFilters(row, filters));
const selectedSessionId = getSelectedSessionId();
const selectedRow = selectedSessionId ? allRows.find((row) => row.session.id === selectedSessionId) : null;