8000 Add HR Zones in activity by AhmadZuhdi · Pull Request #199 · joaovitoriasilva/endurain · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add HR Zones in activity #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 25, 2025
Merged

Conversation

AhmadZuhdi
Copy link
Contributor

Description

this PR adding hr zones calculation based on user birthdate (see https://www.heartonline.org.au/resources/calculators/target-heart-rate-calculator

Screenshot 2025-06-15 113628

@joaovitoriasilva
Copy link
Owner

Hi, thanks for the PR. This makes totally sense. I will review this ASAP :)

What do you think of changing this to a pie chart or a bar chart?

@joaovitoriasilva joaovitoriasilva requested a review from Copilot June 16, 2025 13:58
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds heart rate (HR) zone calculations and display to activities, based on user birthdate.

  • Frontend: passes activity streams to the summary component and adds total/moving times and HR zone UI.
  • Backend: introduces a transform step in the activity streams CRUD to calculate hr_zone_percentages using NumPy.
  • i18n: adds new translation keys for HR and zones.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/app/src/views/ActivityView.vue Passes new activityActivityStreams prop to the summary component
frontend/app/src/components/Activities/ActivitySummaryComponent.vue Displays moving/total time and HR zones; adds hrZones state and getZoneColor helper
frontend/app/src/i18n/us/components/activities/activitySummaryComponent.json Adds translation strings for HR and zone labels
backend/app/activities/activity_streams/schema.py Adds hr_zone_percentages field to the Pydantic schema
backend/app/activities/activity_streams/crud.py Applies transform_activity_streams_hr to calculate HR zones and updates API returns
backend/app/activities/activity_streams/constants.py Defines stream type constants (including unused STREAM_TYPE_HR_ZONES)
Comments suppressed due to low confidence (2)

frontend/app/src/views/ActivityView.vue:6

  • Prop activityActivityStreams is passed but not defined in this component. Ensure you fetch the activity streams in ActivityView.vue and expose them as activityActivityStreams to avoid undefined prop errors.
:activityActivityStreams="activityActivityStreams"

frontend/app/src/components/Activities/ActivitySummaryComponent.vue:254

  • The prop activityActivityStreams is declared with type [Object, null] but is used as an array. Update its type to Array (e.g., type: Array) to reflect correct usage.
activityActivityStreams: {
		type: [Object, null],
		required: true,
	},

Comment on lines 290 to 291
hrZones.value = props.activityActivityStreams.find(stream => stream.hr_zone_percentages).hr_zone_percentages || {};

Copy link
Preview
Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Using onMounted to set hrZones means updates to activityActivityStreams later won’t recalculate zones. Consider using a watch or computed property to react to prop changes.

Suggested change
hrZones.value = props.activityActivityStreams.find(stream => stream.hr_zone_percentages).hr_zone_percentages || {};

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be fine, i dont expect the value to change over time, only the first api call

@AhmadZuhdi
Copy link
Contributor Author
AhmadZuhdi commented Jun 17, 2025

Hi, thanks for the PR. This makes totally sense. I will review this ASAP :)

What do you think of changing this to a pie chart or a bar chart?

Screenshot 2025-06-17 081348
something like this ?

@joaovitoriasilva
Copy link
Owner

Awesome. I would just add the percentage somewhere to make it more easily read.
For reference Garmin one:
image

@AhmadZuhdi
Copy link
Contributor Author

Screenshot 2025-06-17 224857
something like this ?

@joaovitoriasilva
Copy link
Owner

Nice! Really like it

- return transform_activity_streams to  get_public_activity_stream_by_type
-
@joaovitoriasilva joaovitoriasilva self-assigned this Jun 17, 2025
@joaovitoriasilva joaovitoriasilva added the enhancement New feature or request label Jun 17, 2025
@joaovitoriasilva joaovitoriasilva added this to the v0.13.X milestone Jun 17, 2025
[backend] fixed formatting
[backend] changed existing docstrings to be more complete
[backend] changed imports to be consistent with rest of the code
[frontend] fixed formatting
[frontend] set new prop on ActivitySummaryComponent to be not required because it is not always necessary (HomeView)
[frontend] fixed issue onMounted on ActivitySummaryComponent when new prop is null
@joaovitoriasilva joaovitoriasilva moved this from Todo to In Progress in Endurain project Jun 23, 2025
@joaovitoriasilva joaovitoriasilva modified the milestones: v0.13.X, v0.12.X Jun 23, 2025
[frontend] moved HR Zones graph away from ActivitySummaryComponent
[frontend] removed duplicated translation
[frontend] reverted changes on ActivitySummaryComponent since chart was removed
[frontend] moved chart to ActivityMandAbovePillsComponent
[frontend] small adjustments to BarChart
@joaovitoriasilva
Copy link
Owner

Hi! Moved chart to the Graphs section to be aligned with current logic. In the future with other graphs of this type (power for example) this can be revisited. What do you think?
Screenshot 2025-06-23 at 16 16 02

[frontend] moved chart functions to chartUtils file
[frontend] added HR Zones Bar Chart to mobile view
@joaovitoriasilva
Copy link
Owner

Merged on pre-release

@joaovitoriasilva joaovitoriasilva merged commit c9e006a into joaovitoriasilva:master Jun 25, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Endurain project Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants
0