This commit is contained in:
Bastian Wagner
2026-06-19 17:11:39 +02:00
parent 06bdf83657
commit e4f038936a

View File

@@ -1358,11 +1358,18 @@ export class AnalyticsService {
const daysSinceLastRun = lastRun?.startDate ? this.daysBetween(lastRun.startDate, now) : null;
// Faktor 1: Load Ratio (0-100)
const loadFactor = acuteChronicRatio !== null ? Math.min(acuteChronicRatio * 10, 100) : 50;
const loadFactor = acuteChronicRatio === null ? 50 : Math.min(acuteChronicRatio * 10, 100);
// Faktor 2: Intensität - Anteil harter Läufe in den letzten 14 Tagen
const recentRuns = runs.filter((run) => run.startDate !== null && run.startDate !== undefined && this.daysBetween(run.startDate, now) <= 14);
const hardRuns = activityLoads.filter((al) => al.zone === 'hard' && al.activity.startDate !== null && al.activity.startDate !== undefined && this.daysBetween(al.activity.startDate, now) <= 14);
const recentRuns = runs.filter((run) => {
const days = this.daysBetween(run.startDate, now);
return days !== null && days <= 14;
});
const hardRuns = activityLoads.filter((al) => {
if (al.zone !== 'hard') return false;
const days = this.daysBetween(al.activity.startDate, now);
return days !== null && days <= 14;
});
const intensityFactor = recentRuns.length > 0 ? Math.round((hardRuns.length / recentRuns.length) * 100) : 0;
// Faktor 3: Erholung (je mehr Tage seit letztem Lauf, desto besser)
@@ -1406,7 +1413,7 @@ export class AnalyticsService {
const formScore = this.calculateFormScore(activityLoads, now);
// Fatigue: Basierend auf akuter Belastung
const fatigueScore = acuteChronicRatio !== null ? Math.max(0, 100 - (acuteChronicRatio - 1) * 50) : 75;
const fatigueScore = acuteChronicRatio === null ? 75 : Math.max(0, 100 - (acuteChronicRatio - 1) * 50);
// Recovery
const recoveryScore = daysSinceLastRun === null ? 50 :
@@ -1504,6 +1511,7 @@ export class AnalyticsService {
for (let i = sortedRuns.length - 2; i >= 0; i--) {
const currentRunDate = sortedRuns[i].startDate!;
const daysDiff = this.daysBetween(currentRunDate, lastRunDate);
if (daysDiff === null) break;
if (daysDiff === 1) {
streak++;
} else if (daysDiff > 1) {