feat(series): run each round from the series page

Step 3 becomes a rounds table: pick drivers inline (copy from the
previous round, add a late entry), set qualifying rounds/finals/max
cars per heat per round, see the status, and create qualifying and
finals from there. Qualifying heats are now split evenly so nobody
drives alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-11 18:55:36 +02:00
1 parent 581ec2c781
commit b5707f92d1
17 files changed
+447 -39

No files matched your search

+22 -2
View File
@@ -622,6 +622,25 @@ export function findEventTeamForPassing(event, driverId, carId, { getEventTeams
// Qualifying heats as even as possible: 9 drivers with max 8 per heat -> 5 + 4, never 8 + 1
// (someone driving alone). The number of heats follows the number of participants. Order is
// kept; earlier heats get the extra driver.
export function splitIntoBalancedGroups(items, maxSize) {
const list = Array.isArray(items) ? items : [];
if (!list.length) return [];
const groupCount = Math.ceil(list.length / Math.max(1, maxSize));
const base = Math.floor(list.length / groupCount);
const extra = list.length % groupCount;
const groups = [];
let index = 0;
for (let group = 0; group < groupCount; group += 1) {
const size = base + (group < extra ? 1 : 0);
groups.push(list.slice(index, index + size));
index += size;
}
return groups;
}
export function generateQualifyingForRace(event, { buildPracticeStandings, getEventDrivers, state, normalizeStartMode, normalizeSession, uid, chunkArray, clearGeneratedQualifying }) {
const sourceRows = buildPracticeStandings(event);
const fallbackRows =
@@ -648,7 +667,7 @@ export function generateQualifyingForRace(event, { buildPracticeStandings, getEv
? String(event.raceConfig.qualSeedMethod).toLowerCase()
: "best_sum";
const followUpSec = Math.max(0, Number(event.raceConfig?.followUpSec || 0) || 0);
const heats = chunkArray(fallbackRows, carsPerHeat);
const heats = splitIntoBalancedGroups(fallbackRows, carsPerHeat);
let created = 0;
heats.forEach((heatRows, heatIndex) => {
@@ -718,7 +737,8 @@ export function reseedUpcomingQualifying(event, { buildQualifyingStandings, buil
}
const carsPerHeat = Math.max(2, Number(event.raceConfig?.carsPerHeat || 8) || 8);
const heats = chunkArray(sourceRows, carsPerHeat);
// Same even split as generateQualifyingForRace, so reseeded heats line up with the generated ones.
const heats = splitIntoBalancedGroups(sourceRows, carsPerHeat);
const sessionsByRound = new Map();
getSessionsForEvent(event.id)
.filter((session) => session.type === "qualification" && session.generated && session.status === "ready")