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

+6
View File
@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.47.1 - 2026-11-01
### Fixed
- The Winner column in the results archive could name the wrong driver: with equal laps it named whoever crossed the line first after the start, not who finished first. It now uses the session's result, the same as Show and the series standings.
## 1.47.0 - 2026-11-01
### Added
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.47.0",
"version": "1.47.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.47.0",
"version": "1.47.1",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.47.0",
"version": "1.47.1",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+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;
+15
View File
@@ -12,3 +12,18 @@ test("estimated finish: laps and time when a 5-minute heat is up, at the car's r
assert.equal(estimateFinish({ laps: 0, totalElapsedMs: 0 }, 300000), null, "no lap yet");
assert.equal(estimateFinish({ laps: 5, totalElapsedMs: 90000 }, null), null, "untimed session");
});
test("results archive: the winner is the session's result order, not who has a lap stored first", async () => {
const { buildArchiveRows } = await import("../src/results_archive_view.js");
const state = {
sessions: [{ id: "a1", eventId: "e1", name: "A final 1", status: "finished", endedAt: 1 }],
events: [{ id: "e1", classId: "c1", date: "2026-11-01" }],
resultsBySession: { a1: { competitors: { first_over_line: { driverName: "Crossed first", laps: 14 }, winner: { driverName: "Finished first", laps: 14 } } } },
trackLayouts: [],
};
const rows = buildArchiveRows(state, {
getEventName: () => "Race", getClassName: () => "2WD", getTrackLayoutLabel: () => "",
buildLeaderboard: () => [{ driverName: "Finished first" }, { driverName: "Crossed first" }],
});
assert.equal(rows[0].winnerName, "Finished first");
});