Improve training statistics, achievements and stable pace audio
This commit is contained in:
1 parent
82d52ed6cd
commit
4f847610dc
16 files changed
+315
-50
No files matched your search
+29
-4
@@ -64,6 +64,10 @@ const messages = {
|
||||
fiveAverage: "Avg pace, bästa 5 min",
|
||||
splitPassings: "Mellantidspasseringar",
|
||||
bestSplit: "Bästa mellantid",
|
||||
latestSectorGain: "Senaste sektorförbättring",
|
||||
controlZone: "Kontrollzon",
|
||||
outlierLaps: "Avvikande varv",
|
||||
strongFinishes: "Starka avslutningar",
|
||||
pitStops: "Depåstopp",
|
||||
totalPit: "Total depåtid",
|
||||
recentProgress: "Din senaste utveckling",
|
||||
@@ -89,6 +93,8 @@ const messages = {
|
||||
achievement_five_minute: "Fullföljd femminutersstint",
|
||||
achievement_five_minutes_3: "3 fullföljda femminutersstintar",
|
||||
achievement_consistency_5: "Jämnhet under 5 procent",
|
||||
achievement_strong_finish: "Stark avslutning",
|
||||
achievement_clean_five_minute: "Fem minuter utan avvikande varv",
|
||||
achievement_pace_gain: "Förbättrat snittempo",
|
||||
creditTitle: "Din träning räknas",
|
||||
creditBody: "Varje genomfört varv bygger erfarenhet. Du jämförs med din egen utveckling, inte med andra förare.",
|
||||
@@ -97,6 +103,9 @@ const messages = {
|
||||
consistencyCredit: "{value} procentenheter jämnare körning",
|
||||
controlledCredit: "{laps} kontrollerade varv i rad",
|
||||
fiveMinuteCredit: "Du har fullföljt en femminutersstint",
|
||||
sectorCredit: "Sektortiden förbättrad med {lap}",
|
||||
strongFinishCredit: "Stark avslutning med bibehållet tempo",
|
||||
cleanFiveCredit: "Fem minuter utan avvikande varv",
|
||||
buildingCredit: "{laps} varv har redan byggt din erfarenhet",
|
||||
readyCredit: "Första giltiga varvet startar din utvecklingsresa",
|
||||
challenges: "Små utmaningar",
|
||||
@@ -161,6 +170,10 @@ const messages = {
|
||||
fiveAverage: "Average pace, best 5 min",
|
||||
splitPassings: "Split passings",
|
||||
bestSplit: "Best split",
|
||||
latestSectorGain: "Latest sector improvement",
|
||||
controlZone: "Control zone",
|
||||
outlierLaps: "Outlier laps",
|
||||
strongFinishes: "Strong finishes",
|
||||
pitStops: "Pit stops",
|
||||
totalPit: "Total pit time",
|
||||
recentProgress: "Your recent development",
|
||||
@@ -186,6 +199,8 @@ const messages = {
|
||||
achievement_five_minute: "Completed five-minute stint",
|
||||
achievement_five_minutes_3: "3 completed five-minute stints",
|
||||
achievement_consistency_5: "Consistency below 5 percent",
|
||||
achievement_strong_finish: "Strong finish",
|
||||
achievement_clean_five_minute: "Five minutes without outlier laps",
|
||||
achievement_pace_gain: "Improved average pace",
|
||||
creditTitle: "Your practice counts",
|
||||
creditBody: "Every completed lap builds experience. You are compared with your own development, not other drivers.",
|
||||
@@ -194,6 +209,9 @@ const messages = {
|
||||
consistencyCredit: "{value} percentage points more consistent",
|
||||
controlledCredit: "{laps} controlled laps in a row",
|
||||
fiveMinuteCredit: "You completed a five-minute stint",
|
||||
sectorCredit: "Sector time improved by {lap}",
|
||||
strongFinishCredit: "Strong finish with pace maintained",
|
||||
cleanFiveCredit: "Five minutes without outlier laps",
|
||||
buildingCredit: "{laps} laps have already built your experience",
|
||||
readyCredit: "Your first valid lap starts the development journey",
|
||||
challenges: "Small challenges",
|
||||
@@ -260,13 +278,13 @@ function getLocalDayKey(timestamp) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function buildProfileMotivation(stats) {
|
||||
function buildProfileMotivation(stats, channelStats = {}) {
|
||||
const todayKey = getLocalDayKey(Date.now());
|
||||
const today = (Array.isArray(stats?.dailySummaries) ? stats.dailySummaries : []).find((day) => day.dateKey === todayKey);
|
||||
const activeToday = Boolean(today);
|
||||
const todayLaps = Number(today?.laps || 0);
|
||||
const controlled = activeToday ? Number(stats?.controlledLapStreak || 0) : 0;
|
||||
const completedFive = stats?.bestFiveMinuteResult ? 1 : 0;
|
||||
const controlled = activeToday ? Number(stats?.todayControlledLapStreak || 0) : 0;
|
||||
const completedFive = activeToday ? Number(stats?.todayCompletedFiveMinuteStints || 0) : 0;
|
||||
const challenges = [
|
||||
{ id: "Laps", current: todayLaps, target: 20 },
|
||||
{ id: "Controlled", current: controlled, target: 5 },
|
||||
@@ -282,6 +300,9 @@ function buildProfileMotivation(stats) {
|
||||
if (stats?.trendSampleReady && Number(stats.consistencyTrendPct || 0) > 0.1) credits.push(t("consistencyCredit", { value: Number(stats.consistencyTrendPct).toFixed(1) }));
|
||||
if (controlled >= 5) credits.push(t("controlledCredit", { laps: controlled }));
|
||||
if (completedFive) credits.push(t("fiveMinuteCredit"));
|
||||
if (Number(channelStats.latestSplitGainMs || 0) > 0) credits.push(t("sectorCredit", { lap: formatLap(channelStats.latestSplitGainMs) }));
|
||||
if (Number(stats?.todayStrongFinishStints || 0) > 0) credits.push(t("strongFinishCredit"));
|
||||
if (Number(stats?.todayCleanFiveMinuteStints || 0) > 0) credits.push(t("cleanFiveCredit"));
|
||||
if (!credits.length && Number(stats?.totalLaps || 0) > 0) credits.push(t("buildingCredit", { laps: stats.totalLaps }));
|
||||
if (!credits.length) credits.push(t("readyCredit"));
|
||||
return { challenges, credits: credits.slice(0, 3) };
|
||||
@@ -299,7 +320,7 @@ function renderProfile(data) {
|
||||
const recommendation = activeClass?.recommendation || data.recommendation;
|
||||
const goals = activeClass?.goals || data.goals || [];
|
||||
const currentSession = activeClass?.currentSession || data.currentSession;
|
||||
const motivation = buildProfileMotivation(stats);
|
||||
const motivation = buildProfileMotivation(stats, channelStats);
|
||||
const recommendationText = recommendationCopy(recommendation);
|
||||
const timerState = readTimerState();
|
||||
const timerConfig = getTimerConfig(timerState);
|
||||
@@ -462,11 +483,15 @@ function renderProfile(data) {
|
||||
<div class="profile-card-head"><h2>${escapeHtml(t("performance"))}</h2></div>
|
||||
<div class="profile-performance-stats">
|
||||
<div><span>${escapeHtml(t("stints"))}</span><strong>${Number(stats.stintCount || 0)}</strong></div>
|
||||
<div><span>${escapeHtml(t("controlZone"))}</span><strong>${stats.controlZoneMaxMs ? `${formatLap(stats.controlZoneMinMs)} - ${formatLap(stats.controlZoneMaxMs)}` : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("outlierLaps"))}</span><strong>${Number(stats.outlierLaps || 0)}</strong></div>
|
||||
<div><span>${escapeHtml(t("strongFinishes"))}</span><strong>${Number(stats.strongFinishStints || 0)}</strong></div>
|
||||
<div><span>${escapeHtml(t("bestThree"))}</span><strong>${stats.bestThreeConsecutive ? `3/${formatRaceResultTime(stats.bestThreeConsecutive.totalMs)}` : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("bestFive"))}</span><strong>${stats.bestFiveMinuteResult ? `${stats.bestFiveMinuteResult.lapCount}/${formatRaceResultTime(stats.bestFiveMinuteResult.totalMs)}` : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("fiveAverage"))}</span><strong>${stats.bestFiveMinuteResult ? formatLap(stats.bestFiveMinuteResult.averageLapMs) : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("splitPassings"))}</span><strong>${Number(channelStats.splitCount || 0)}</strong></div>
|
||||
<div><span>${escapeHtml(t("bestSplit"))}</span><strong>${channelStats.splitCount ? formatLap(channelStats.bestSplitMs) : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("latestSectorGain"))}</span><strong>${channelStats.latestSplitGainMs ? formatLap(channelStats.latestSplitGainMs) : "-"}</strong></div>
|
||||
<div><span>${escapeHtml(t("pitStops"))}</span><strong>${Number(channelStats.pitStopCount || 0)}</strong></div>
|
||||
<div><span>${escapeHtml(t("totalPit"))}</span><strong>${channelStats.pitStopCount ? formatRaceResultTime(channelStats.totalPitMs) : "-"}</strong></div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user