feat(series): next-step button per round and Race Day next session (1.44.0)
This commit is contained in:
1 parent
dbda06d101
commit
71aa149a4d
12 files changed
+145
-10
No files matched your search
@@ -752,6 +752,28 @@ export function generateQualifyingForRace(event, { buildPracticeStandings, getEv
|
||||
|
||||
|
||||
|
||||
// The order a race's sessions are run in: practice, then qualifying round by round (Q1 H1,
|
||||
// Q1 H2, Q2 H1 ... - generation stores them heat by heat), then finals leg by leg with the
|
||||
// lowest final first (C1, B1, A1, C2 ...). Anything else keeps the order it was created in.
|
||||
export function orderSessionsForRunning(sessions = []) {
|
||||
const key = (session, index) => {
|
||||
if (["practice", "free_practice", "open_practice"].includes(session.type)) return [0, 0, 0, index];
|
||||
if (session.type === "qualification") {
|
||||
const parsed = parseQualifyingHeatName(session.name);
|
||||
return parsed ? [1, parsed.round, parsed.heat, index] : [1, 0, 0, index];
|
||||
}
|
||||
if (session.type === "final") {
|
||||
const match = String(session.name || "").match(/^([A-Z])\b.*?(\d+)\s*$/);
|
||||
return match ? [2, Number(match[2]), -(match[1].charCodeAt(0)), index] : [2, 0, 0, index];
|
||||
}
|
||||
return [1, 0, 0, index];
|
||||
};
|
||||
return sessions
|
||||
.map((session, index) => ({ session, key: key(session, index) }))
|
||||
.sort((a, b) => a.key.reduce((diff, value, i) => diff || value - b.key[i], 0))
|
||||
.map((item) => item.session);
|
||||
}
|
||||
|
||||
// Generated qualifying sessions are named "Q<round> H<heat>" (see generateQualifyingForRace)
|
||||
// with no separate round/heat fields of their own - shared here so every place that needs
|
||||
// to know which round/heat a session belongs to parses the same way.
|
||||
|
||||
Reference in new issue
Block a user