Classify free intensity duration to separate zone
This commit is contained in:
parent
c69a24c0e3
commit
c1a435e4d0
|
|
@ -1,6 +1,6 @@
|
|||
import { Interval } from "../ast";
|
||||
import { Duration } from "../Duration";
|
||||
import { ConstantIntensity, RangeIntensity } from "../Intensity";
|
||||
import { ConstantIntensity, FreeIntensity, RangeIntensity } from "../Intensity";
|
||||
import { zoneDistribution } from "./zoneDistribution";
|
||||
|
||||
const testZoneDistribution = (intervals: Interval[]) =>
|
||||
|
|
@ -102,4 +102,24 @@ describe("zoneDistribution()", () => {
|
|||
["Freeride", 0],
|
||||
]);
|
||||
});
|
||||
|
||||
it("places free-intensity duration to special free-zone", () => {
|
||||
const intervals: Interval[] = [
|
||||
{
|
||||
type: "Interval",
|
||||
duration: new Duration(60),
|
||||
intensity: new FreeIntensity(),
|
||||
comments: [],
|
||||
},
|
||||
];
|
||||
expect(testZoneDistribution(intervals)).toEqual([
|
||||
["Z1: Recovery", 0],
|
||||
["Z2: Endurance", 0],
|
||||
["Z3: Tempo", 0],
|
||||
["Z4: Threshold", 0],
|
||||
["Z5: VO2 Max", 0],
|
||||
["Z6: Anaerobic", 0],
|
||||
["Freeride", 60],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Interval } from "../ast";
|
||||
import { Duration } from "../Duration";
|
||||
import { RangeIntensity } from "../Intensity";
|
||||
import { intensityValueToZoneType, ZoneType } from "../ZoneType";
|
||||
import { intervalsToIntensityNumbers } from "./intervalsToIntensityNumbers";
|
||||
|
||||
|
|
@ -19,8 +20,14 @@ const emptyZones = (): Record<ZoneType, NumericZoneDuration> => ({
|
|||
export const zoneDistribution = (intervals: Interval[]): ZoneDuration[] => {
|
||||
const zones = emptyZones();
|
||||
|
||||
intervalsToIntensityNumbers(intervals).forEach((intensity) => {
|
||||
zones[intensityValueToZoneType(intensity)].duration++;
|
||||
intervals.forEach((interval) => {
|
||||
if (interval.intensity instanceof RangeIntensity) {
|
||||
intervalsToIntensityNumbers([interval]).forEach((intensityValue) => {
|
||||
zones[intensityValueToZoneType(intensityValue)].duration++;
|
||||
});
|
||||
} else {
|
||||
zones[interval.intensity.zone].duration += interval.duration.seconds;
|
||||
}
|
||||
});
|
||||
|
||||
return Object.values(zones).map(({ duration, ...rest }) => ({ duration: new Duration(duration), ...rest }));
|
||||
|
|
|
|||
|
|
@ -288,13 +288,13 @@ Normalized intensity: 71%
|
|||
TSS: 37
|
||||
|
||||
Zone Distribution:
|
||||
35 min - Z1: Recovery
|
||||
15 min - Z1: Recovery
|
||||
4 min - Z2: Endurance
|
||||
0 min - Z3: Tempo
|
||||
0 min - Z4: Threshold
|
||||
3 min - Z5: VO2 Max
|
||||
2 min - Z6: Anaerobic
|
||||
0 min - Freeride
|
||||
20 min - Freeride
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue