feat(profile): 'My race today' on the driver's mobile profile - next heats, grid place, marshal duties and today's results (1.89.31)

This commit is contained in:
larssand committed 2026-11-14 16:38:08 +01:00
1 parent 163e82224c
commit 01998952a7
14 files changed
+222 -3

No files matched your search

+14
View File
@@ -722,6 +722,19 @@ app.get(["/public-overlay", "/public-overlay/:mode"], (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
// "My race today" (src/my_race_logic.js): the race master posts its day snapshot here; the public
// profile picks out the driver's own heats. Kept in a file of its own so it never races app state.
const PUBLIC_RACE_DAY_FILE = path.join(DB_DIR, "public_race_day.json");
let publicRaceDaySnapshot = null;
try { publicRaceDaySnapshot = JSON.parse(fs.readFileSync(PUBLIC_RACE_DAY_FILE, "utf8")); } catch { publicRaceDaySnapshot = null; }
app.post("/api/public-race-day", (req, res) => {
const snapshot = publicTrainingProfile.sanitizePublicRaceDaySnapshot(req.body);
if (!snapshot) { res.status(400).json({ error: "invalid snapshot" }); return; }
publicRaceDaySnapshot = snapshot;
try { fs.writeFileSync(PUBLIC_RACE_DAY_FILE, JSON.stringify(snapshot)); } catch { /* memory copy still serves */ }
res.json({ ok: true });
});
app.get("/public-training/api/:shareToken", (req, res) => {
try {
const stored = readStoredAppState();
@@ -736,6 +749,7 @@ app.get("/public-training/api/:shareToken", (req, res) => {
res.status(404).json({ error: "Profile not found" });
return;
}
profile.raceToday = publicTrainingProfile.pickDriverRaceDay(publicRaceDaySnapshot, publicTrainingProfile.publicProfileDriverIds(stored.state, String(req.params.shareToken || "")));
res.setHeader("Cache-Control", "no-store");
res.json(profile);
} catch (error) {