Skip to content

feat: show heart rate on activity page - #144

Merged
0jonjo merged 2 commits into
mainfrom
feat/heart-rate-display
Aug 15, 2026
Merged

feat: show heart rate on activity page#144
0jonjo merged 2 commits into
mainfrom
feat/heart-rate-display

Conversation

@0jonjo

@0jonjo 0jonjo commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Display average and peak heart rate for runs on the activity show page (runs.hr_avg / runs.hr_peak, recorded since v0.3.0 but never surfaced in the UI).
  • Progressive disclosure: the stat block only renders when hr_avg is present, matching the existing VO2max pattern.
  • When the profile has an hr_max, an additional zone badge (Zone 1-5) shows which %HRmax training zone the run's average heart rate falls in, computed via Calcpace#hr_zones_from_max (same gem API already used by DashboardFitness#hr_zones). The lookup helper (hr_zone_for) returns nil — hiding the badge — when hr_avg falls outside every zone (stale HRmax, sensor glitch).
  • Added stat_heart_rate, hr_peak_label and hr_zone_label i18n 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

  • New tests: helper tests for hr_zone_for / hr_zone_badge_class in test/helpers/application_helper_test.rb; request tests for presence/absence of the heart-rate stat and zone badge in test/controllers/activities_controller_test.rb
  • bin/rails test — 508 runs, 0 failures
  • bundle exec rubocop — no offenses
  • bundle exec i18n-tasks missing / unused — clean for the new keys

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.
Copilot AI lite review requested due to automatic review settings August 15, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.
@0jonjo
0jonjo merged commit 2c0e807 into main Aug 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants