Scope driver training-profile stats by track layout too

The user pointed out that track layout changes matter most for Open
Practice/training, not races - so the admin Training page and the
driver's own mobile profile (server/public_training_profile.js, the
actual thing most viewed after practice) needed the same layout
scoping already applied to the live "track record" audio cue.

Every stat now splits into two groups: lifetime/commitment numbers
(total laps, sessions, training days, milestone badges) still read a
driver's whole history, since a track rebuild doesn't erase past
practice. Pace/record/consistency numbers (personal best, recent-pace
trend, consistency spread, the "stable pace" control zone, stint
achievements, "best stint") now read only laps tagged with whichever
layout is currently active. Each ledger entry is tagged with
trackLayoutId at the moment it's synced from a session, so it survives
the source session later being deleted.

Verified with new unit tests covering both implementations and a real
headless-browser run confirming both the admin page and the actual
public mobile profile show the current-layout best lap (never a
faster but incomparable old-layout one) while keeping the correct
full lifetime lap count in both places.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
larssand
2026-09-10 14:37:32 +02:00
parent fd6efe2c7e
commit a7272d3844
8 changed files with 169 additions and 18 deletions

View File

@@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.10.0 - 2026-09-10
### Added
- Track layouts now also scope the driver training profile's personal-best, pace-trend and consistency statistics (both on the admin Training page and the driver's own mobile link) - the part of the app actually most affected by a layout change, since it's built from ongoing Open Practice. Lifetime totals (laps, sessions, training days, milestone badges) still count everything a driver has ever done; only pace/record comparisons are now scoped to the currently active layout.
## 1.9.0 - 2026-09-10
### Added