Add tags to generated ZWO XML

This commit is contained in:
Rene Saarsoo 2020-10-06 16:47:48 +03:00
parent b1c42ad326
commit 8e4c72233c
4 changed files with 26 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Description:
you will be scored on the final 20 minute segment. you will be scored on the final 20 minute segment.
Upon saving your ride, you will be notified if your FTP improved. Upon saving your ride, you will be notified if your FTP improved.
Tags: FTP, Test
Warmup: 5:00 30%..70% Warmup: 5:00 30%..70%
@ 00:20 Welcome to the FTP test @ 00:20 Welcome to the FTP test

View File

@ -3,6 +3,7 @@ Description:
Named after the number 90 in Danish, this workout is focused sweet spot training, centered around 90% of FTP. Named after the number 90 in Danish, this workout is focused sweet spot training, centered around 90% of FTP.
This pairs with Devedeset (90 in Croatian) and Novanta (90 in Italian) to make up the sweet spot trifecta in this plan. This pairs with Devedeset (90 in Croatian) and Novanta (90 in Italian) to make up the sweet spot trifecta in this plan.
The workouts are alphabetically ordered from easiest to hardest, so enjoy the middle of these three challenging workouts today... The workouts are alphabetically ordered from easiest to hardest, so enjoy the middle of these three challenging workouts today...
Tags: Intervals
Warmup: 7:00 25%..75% Warmup: 7:00 25%..75%
Interval: 00:30 95rpm 95% Interval: 00:30 95rpm 95%

View File

@ -96,13 +96,20 @@ const generateInterval = (interval: Interval | RepeatedInterval): xml.XmlObject
} }
}; };
export const generateZwo = ({ name, author, description, intervals }: Workout): string => { const generateTag = (name: string): xml.XmlObject => {
return {
tag: [{ _attr: { name } }],
};
};
export const generateZwo = ({ name, author, description, tags, intervals }: Workout): string => {
return xml( return xml(
{ {
workout_file: [ workout_file: [
{ name: name }, { name: name },
{ author: author }, { author: author },
{ description: description }, { description: description },
{ tags: tags.map(generateTag) },
{ sportType: "bike" }, { sportType: "bike" },
{ workout: detectRepeats(intervals).map(generateInterval) }, { workout: detectRepeats(intervals).map(generateInterval) },
], ],

View File

@ -5,6 +5,8 @@ exports[`Generate ZWO examples/comments.txt 1`] = `
<name>Workout with comments</name> <name>Workout with comments</name>
<author></author> <author></author>
<description></description> <description></description>
<tags>
</tags>
<sportType>bike</sportType> <sportType>bike</sportType>
<workout> <workout>
<Warmup Duration=\\"600\\" PowerLow=\\"0.25\\" PowerHigh=\\"0.75\\"> <Warmup Duration=\\"600\\" PowerLow=\\"0.25\\" PowerHigh=\\"0.75\\">
@ -70,6 +72,8 @@ exports[`Generate ZWO examples/darth-vader.txt 1`] = `
<name>Darth Vader</name> <name>Darth Vader</name>
<author>HumanPowerPerformance.com</author> <author>HumanPowerPerformance.com</author>
<description>Sign up for coaching with HumanPowerPerformance.com and get custom workouts and training plans</description> <description>Sign up for coaching with HumanPowerPerformance.com and get custom workouts and training plans</description>
<tags>
</tags>
<sportType>bike</sportType> <sportType>bike</sportType>
<workout> <workout>
<SteadyState Duration=\\"300\\" Power=\\"0.55\\"> <SteadyState Duration=\\"300\\" Power=\\"0.55\\">
@ -93,6 +97,12 @@ Pace yourself and try to go as hard as you can sustain for the entire 20 minutes
you will be scored on the final 20 minute segment. you will be scored on the final 20 minute segment.
Upon saving your ride, you will be notified if your FTP improved.</description> Upon saving your ride, you will be notified if your FTP improved.</description>
<tags>
<tag name=\\"FTP\\">
</tag>
<tag name=\\"Test\\">
</tag>
</tags>
<sportType>bike</sportType> <sportType>bike</sportType>
<workout> <workout>
<Warmup Duration=\\"300\\" PowerLow=\\"0.3\\" PowerHigh=\\"0.7\\"> <Warmup Duration=\\"300\\" PowerLow=\\"0.3\\" PowerHigh=\\"0.7\\">
@ -154,6 +164,10 @@ exports[`Generate ZWO examples/halvfems.txt 1`] = `
<description>Named after the number 90 in Danish, this workout is focused sweet spot training, centered around 90% of FTP. <description>Named after the number 90 in Danish, this workout is focused sweet spot training, centered around 90% of FTP.
This pairs with Devedeset (90 in Croatian) and Novanta (90 in Italian) to make up the sweet spot trifecta in this plan. This pairs with Devedeset (90 in Croatian) and Novanta (90 in Italian) to make up the sweet spot trifecta in this plan.
The workouts are alphabetically ordered from easiest to hardest, so enjoy the middle of these three challenging workouts today...</description> The workouts are alphabetically ordered from easiest to hardest, so enjoy the middle of these three challenging workouts today...</description>
<tags>
<tag name=\\"Intervals\\">
</tag>
</tags>
<sportType>bike</sportType> <sportType>bike</sportType>
<workout> <workout>
<Warmup Duration=\\"420\\" PowerLow=\\"0.25\\" PowerHigh=\\"0.75\\"> <Warmup Duration=\\"420\\" PowerLow=\\"0.25\\" PowerHigh=\\"0.75\\">
@ -224,6 +238,8 @@ This session is designed to increase your FTP from below.
Working predominately aerobic metabolism. Working predominately aerobic metabolism.
In time your body will become more comfortable at these powers In time your body will become more comfortable at these powers
and your FTP will increase.</description> and your FTP will increase.</description>
<tags>
</tags>
<sportType>bike</sportType> <sportType>bike</sportType>
<workout> <workout>
<Warmup Duration=\\"1200\\" PowerLow=\\"0.45\\" PowerHigh=\\"0.75\\"> <Warmup Duration=\\"1200\\" PowerLow=\\"0.45\\" PowerHigh=\\"0.75\\">