Include xp data to stats() output

This commit is contained in:
Rene Saarsoo 2020-11-20 17:56:19 +02:00
parent 410edccf66
commit b269a77219
2 changed files with 11 additions and 1 deletions

View File

@ -1,10 +1,12 @@
import { Workout } from "../ast";
import { detectRepeats } from "../detectRepeats";
import { Duration } from "../Duration";
import { Intensity } from "../Intensity";
import { averageIntensity } from "./averageIntensity";
import { normalizedIntensity } from "./normalizedIntensity";
import { totalDuration } from "./totalDuration";
import { tss } from "./tss";
import { xp } from "./xp";
import { zoneDistribution, ZoneDuration } from "./zoneDistribution";
export type Stats = {
@ -12,6 +14,7 @@ export type Stats = {
averageIntensity: Intensity;
normalizedIntensity: Intensity;
tss: number;
xp: number;
zones: ZoneDuration[];
};
@ -24,11 +27,12 @@ export const stats = ({ intervals }: Workout): Stats => {
averageIntensity: averageIntensity(intervals),
normalizedIntensity: normalizedIntensity(intervals),
tss: tss(duration, normIntensity),
xp: xp(detectRepeats(intervals)),
zones: zoneDistribution(intervals),
};
};
export const formatStats = ({ totalDuration, averageIntensity, normalizedIntensity, tss, zones }: Stats) => {
export const formatStats = ({ totalDuration, averageIntensity, normalizedIntensity, tss, xp, zones }: Stats) => {
return `
Total duration: ${(totalDuration.seconds / 60).toFixed()} minutes
@ -36,6 +40,7 @@ Average intensity: ${(averageIntensity.value * 100).toFixed()}%
Normalized intensity: ${(normalizedIntensity.value * 100).toFixed()}%
TSS: ${tss.toFixed()}
XP: ${xp}
Zone Distribution:
${zones.map(({ name, duration }) => `${(duration.seconds / 60).toFixed().padStart(3)} min - ${name}`).join("\n")}

View File

@ -262,6 +262,7 @@ Average intensity: 60%
Normalized intensity: 74%
TSS: 22
XP: 173
Zone Distribution:
15 min - Z1: Recovery
@ -282,6 +283,7 @@ Average intensity: 79%
Normalized intensity: 84%
TSS: 51
XP: 502
Zone Distribution:
10 min - Z1: Recovery
@ -302,6 +304,7 @@ Average intensity: 36%
Normalized intensity: 71%
TSS: 37
XP: 336
Zone Distribution:
15 min - Z1: Recovery
@ -322,6 +325,7 @@ Average intensity: 74%
Normalized intensity: 81%
TSS: 68
XP: 628
Zone Distribution:
22 min - Z1: Recovery
@ -342,6 +346,7 @@ Average intensity: 69%
Normalized intensity: 78%
TSS: 81
XP: 755
Zone Distribution:
42 min - Z1: Recovery