Add support for descent
Descent is Ascent + (Start Elevation - End Elevation). Start Elevation and End Elevation can be obtained from AltitudeStream.
Hi @dblock I'd like to take a shot at this, as I need to learn Ruby and am familiar with the Strava API. However, I can't think of a good spot to put a total_elevation_loss method. The main problem is that calculating elevation loss requires data from two different endpoints (Stream for start and end elevation and Activity for total elevation gain). Are there any examples in the library of models generated through multiple resource requests? I couldn't find any.
I can see two options where the user is responsible for getting the supplemental data:
- Add
total_elevation_lossmethods to theElevationmixin. The altitude stream is a required parameter. - Or, create an
AltitudeStreamclass which is a subclass ofStream. Addtotal_elevation_lossmethods to it, which have a required total elevation gain parameter.- Alternatively,
AltitudeStreammethods could compute total elevation loss/gain directly from the stream's data. I am not sure if this will match what Strava calculates exactly.
- Alternatively,
Which of these would fit best with the library? Or, is this probably something that users need to be responsible for computing?
I think we should think about it backwards. Let's start with the right interfaces at the model level first, then we can rethink where things go if they need to be in mixins. Mixins are just ways to reuse common functionality.
So, which model(s) need(s) total_elevation_loss? Start there and implement them in any way that works, and we can refactor into mixins later.
Okay, that makes sense. Just thinking about what each model class represents, activity_total, activity, explorer_segment, lap, route, segment, and split could all have a total_elevation_loss property. And, all except explorer_segement use the elevation mixin already. Since explorer_segement doesn't currently have any elevation properties, do you think they should all be added? I don't think adding descent by itself makes sense.
I'll start with the others though, and see what implementing a total_elevation_loss property looks like.
Okay, that makes sense. Just thinking about what each model class represents,
activity_total,activity,explorer_segment,lap,route,segment, andsplitcould all have atotal_elevation_lossproperty. And, all exceptexplorer_segementuse the elevation mixin already. Sinceexplorer_segementdoesn't currently have any elevation properties, do you think they should all be added? I don't think adding descent by itself makes sense.
If they exist on that model, yes.
I'll start with the others though, and see what implementing a
total_elevation_lossproperty looks like.
👍