feat: show heart rate on activity page - #144
Merged
Merged
Conversation
Display avg/peak heart rate for runs on the activity show page, progressively disclosed like the existing VO2max block. When the profile has an hr_max, an additional zone badge shows which of the five %HRmax training zones the run's average heart rate falls in, computed via Calcpace#hr_zones_from_max. Adds stat_heart_rate, hr_peak_label and hr_zone_label i18n keys to all 15 locales.
Strap dropouts arrive as hr_avg/hr_peak 0.0, which .present? treats as a real reading. Guard both stats with .to_f.positive?, same pattern already used by ContextualVo2max.hr_args. Also drop activity.show.hr_zone_label, byte-identical across all 15 locales to the existing activities.index.zones_hr_zone, and reuse that key from the activity show view instead.
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.
Summary
runs.hr_avg/runs.hr_peak, recorded since v0.3.0 but never surfaced in the UI).hr_avgis present, matching the existing VO2max pattern.hr_max, an additional zone badge (Zone 1-5) shows which %HRmax training zone the run's average heart rate falls in, computed viaCalcpace#hr_zones_from_max(same gem API already used byDashboardFitness#hr_zones). The lookup helper (hr_zone_for) returnsnil— hiding the badge — whenhr_avgfalls outside every zone (stale HRmax, sensor glitch).stat_heart_rate,hr_peak_labelandhr_zone_labeli18n keys to all 15 locales, reusing the existing wording from the dashboard's training-zones partial (activities.index.zones_hr_title/zones_hr_zone) for consistency.Test plan
hr_zone_for/hr_zone_badge_classintest/helpers/application_helper_test.rb; request tests for presence/absence of the heart-rate stat and zone badge intest/controllers/activities_controller_test.rbbin/rails test— 508 runs, 0 failuresbundle exec rubocop— no offensesbundle exec i18n-tasks missing/unused— clean for the new keys