Add total_elevation_gain and total_elevation_loss to Stream - #105
Merged
Merged
Conversation
Danger ReportNo issues found. |
… from altitude data Closes #54. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dblock
force-pushed
the
dblock/54-total-elevation-loss
branch
from
August 24, 2026 20:44
8b30eae to
5c15183
Compare
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #54.
Strava's API doesn't provide a native
total_elevation_loss(descent) property on any model. As discussed in the issue, computing it requires either cross-referencing data from multiple endpoints (e.g.Activityfor gain plusStreamfor start/end elevation), or computing gain/loss directly from an altitude stream's data points.This PR takes the self-contained approach: it adds
total_elevation_gainandtotal_elevation_lossmethods (plus formatted_shelpers) toStrava::Models::Stream, computed by summing the positive/negative deltas between consecutive altitude data points. This requires only a singlealtitudestream request and no cross-model composition.Changes
total_elevation_gain,total_elevation_loss,total_elevation_gain_sandtotal_elevation_loss_stoStrava::Models::Stream.spec/strava/models/stream_spec.rb.