When I pull a summary of activities using the “activities” API end point one of the standard fields is Total Elevation Gain. Is it possible to also get Total Elevation Loss as a standard field.
I appreciate this is probably possible by adding a custom field, but I would then need to get teams to add this field to each rider and reprocess lots of historic data, and I’m lazy!!
I finally got this done. For activities from fit files the total_ascent and total_descent fields from the session message are used. Otherwise they are computed from the altitude stream.
I’ve tried to scrape together something that resembles javascript in order to pull total_descent from the lap message in a FIT file in order to have it as a custom interval field within alpine ski activities. No luck.
Custom activity fields allow for using FIT file fields. Interval fields do not.
Would someone mind helping me pull and displaying the total_descent data for each lap (run/interval) in alpine skiing?
Yes, but that doesn’t provide an option to choose the FIT file field to use.
In custom activity fields that box doesn’t need to be checked to choose the FIT file field.
I just don’t know how to write a script to extract the lap data.
{
// Find Index
const lapNumber = activity.icu_intervals.findIndex(lap => lap.start_index === interval.start_index);
// Get total descent of lap
const total_descent = lapNumber !== -1
? icu.fit.lap[lapNumber].total_descent.value
: null; // nothing found
total_descent;
}
This assumed that your intervals has the same length as your laps (so number of laps === number of intervals).
You have to reprocess (not reanalyze!) your old activity to check if it works, because fit files calculations will be executed before analyzing. (New ones should work without reprocessing, if you have the „use laps for intervals“ settings ticked.)
There’s something odd. The descents for each lap don’t match the FIT file data. Is the script incrementing too much? Based on the output, it looks like it’s incrementing by 3.
Then there are too much intervals. Each recovery is counted as an interval too. So, if you have 27 laps, and 27 active intervals + the recovery intervals in between. Usually there should be no recovery interval, if all intervals are created from laps.
But if you consider only the work intervals, then this should work:
{
let total_descent=0;
if (interval.type === "WORK") {
let lapNumber = 0;
for (const lap of activity.icu_intervals) {
if (lap.start_index === interval.start_index) {
break;
}
if (lap.type === "WORK") {
lapNumber++;
}
}
total_descent = icu.fit.lap[lapNumber].total_descent.value;
}
total_descent;
}
Thanks for adding total_descent support recently — that’s super useful!
I’m a gravity / enduro mountain biker, and I’d love to track my total elevation loss per month as a custom chart, just like we can do for elev_gain.
However, I haven’t found a way to create such a chart using the total_descent field — it doesn’t seem to appear in the chart builder or dashboard metrics.
Has anyone been able to build a monthly or weekly elevation loss graph ?
Is total_descent available for use in custom charts yet?
Would love to know if this is possible or on the roadmap — this would be very helpful for riders like me who focus on descending load.