feat(training): base training stats on practice, keep race laps separate
Training stats count Open/Free practice by default; laps from qualifying, heats and finals are kept and shown under Based on: Races or All, marked with race, session and series. Races are listed per race session and never split into stints. Same picker in the mobile profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a9379aa83
commit
af79b610db
15 files changed
+377
-42
No files matched your search
@@ -8,6 +8,7 @@ const DEFAULT_TIMER_CONFIG = Object.freeze({ pushMinutes: 10, controlMinutes: 10
|
||||
const MAX_TIMER_BLOCK_MINUTES = 120;
|
||||
let selectedClassId = new URLSearchParams(window.location.search).get("class") || "";
|
||||
let selectedLayout = new URLSearchParams(window.location.search).get("layout") || "current";
|
||||
let selectedSource = new URLSearchParams(window.location.search).get("source") || "practice";
|
||||
|
||||
const messages = {
|
||||
sv: {
|
||||
@@ -23,6 +24,10 @@ const messages = {
|
||||
development: "Förarutveckling",
|
||||
class: "Klass",
|
||||
layoutStats: "Banlayout",
|
||||
lapSource: "Underlag",
|
||||
lapSourcePractice: "Träning",
|
||||
lapSourceRace: "Race 🏁",
|
||||
lapSourceAll: "Alla",
|
||||
layoutCurrent: "Aktiv layout",
|
||||
layoutNone: "Utan layout (före första layouten)",
|
||||
layoutAll: "Alla layouter",
|
||||
@@ -193,6 +198,10 @@ const messages = {
|
||||
development: "Driver development",
|
||||
class: "Class",
|
||||
layoutStats: "Track layout",
|
||||
lapSource: "Based on",
|
||||
lapSourcePractice: "Practice",
|
||||
lapSourceRace: "Races 🏁",
|
||||
lapSourceAll: "All",
|
||||
layoutCurrent: "Current layout",
|
||||
layoutNone: "No layout (before the first layout)",
|
||||
layoutAll: "All layouts",
|
||||
@@ -647,6 +656,7 @@ function renderProfile(data) {
|
||||
${classProfiles.length > 1 ? `<label class="profile-class-select"><span>${escapeHtml(t("class"))}</span><select id="profileClass">${classOptions}</select></label>` : activeClass?.className ? `<span class="profile-pill">${escapeHtml(activeClass.className)}</span>` : ""}
|
||||
${activeClass?.brand ? `<span class="profile-pill">${escapeHtml(activeClass.brand)}</span>` : ""}
|
||||
${renderLayoutSelect(data.trackLayouts)}
|
||||
${renderSourceSelect(data.lapSource)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -942,6 +952,14 @@ function renderProfile(data) {
|
||||
window.history.replaceState({}, "", nextUrl);
|
||||
loadProfile();
|
||||
});
|
||||
document.getElementById("profileSource")?.addEventListener("change", (event) => {
|
||||
selectedSource = String(event.currentTarget.value || "practice");
|
||||
const nextUrl = new URL(window.location.href);
|
||||
if (selectedSource !== "practice") nextUrl.searchParams.set("source", selectedSource);
|
||||
else nextUrl.searchParams.delete("source");
|
||||
window.history.replaceState({}, "", nextUrl);
|
||||
loadProfile();
|
||||
});
|
||||
document.getElementById("profileClass")?.addEventListener("change", (event) => {
|
||||
selectedClassId = String(event.currentTarget.value || "");
|
||||
const nextUrl = new URL(window.location.href);
|
||||
@@ -1308,6 +1326,15 @@ function renderLayoutSelect(trackLayouts) {
|
||||
</select></label>`;
|
||||
}
|
||||
|
||||
// Practice by default; race laps (qualifying, heats, finals) only on request.
|
||||
function renderSourceSelect(source) {
|
||||
const selected = source || "practice";
|
||||
const option = (value, label) => `<option value="${value}" ${selected === value ? "selected" : ""}>${escapeHtml(label)}</option>`;
|
||||
return `<label class="profile-class-select"><span>${escapeHtml(t("lapSource"))}</span><select id="profileSource">
|
||||
${option("practice", t("lapSourcePractice"))}${option("race", t("lapSourceRace"))}${option("all", t("lapSourceAll"))}
|
||||
</select></label>`;
|
||||
}
|
||||
|
||||
async function loadProfile(background = false) {
|
||||
if (profileConnection.loading || (background && profileIsBeingEdited())) return;
|
||||
profileConnection.loading = true;
|
||||
@@ -1330,6 +1357,7 @@ async function loadProfile(background = false) {
|
||||
const stepTrainingRun = readExerciseRunState("steptraining");
|
||||
if (stepTrainingRun) apiUrl.searchParams.set("stepTrainingStartedAgoMs", String(Math.max(0, Date.now() - stepTrainingRun.startedAt)));
|
||||
if (selectedLayout !== "current") apiUrl.searchParams.set("layout", selectedLayout);
|
||||
if (selectedSource !== "practice") apiUrl.searchParams.set("source", selectedSource);
|
||||
const response = await fetch(apiUrl, { cache: "no-store", signal: controller.signal });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
const data = await response.json();
|
||||
|
||||
Reference in new issue
Block a user