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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/app/activities/activity_streams/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Stream type constants for activity streams
STREAM_TYPE 8000 _HR = 1
STREAM_TYPE_POWER = 2
STREAM_TYPE_CADENCE = 3
STREAM_TYPE_ELEVATION = 4
STREAM_TYPE_SPEED = 5
STREAM_TYPE_PACE = 6
STREAM_TYPE_MAP = 7
319 changes: 265 additions & 54 deletions backend/app/activities/activity_streams/crud.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions backend/app/activities/activity_streams/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@


class ActivityStreams(BaseModel):
"""
Represents a stream of activity data associated with an activity.

Attributes:
id (int | None): Unique identifier for the activity stream (optional).
activity_id (int): Identifier of the related activity.
stream_type (int): Type of the stream (e.g., GPS, heart rate, etc.).
stream_waypoints (List[dict]): List of waypoints or data points in the stream.
strava_activity_stream_id (int | None): Identifier for the corresponding Strava activity stream (optional).
hr_zone_percentages (dict | None): Heart rate zone percentages for the activity (optional).
"""
id: int | None = None
activity_id: int
stream_type: int
stream_waypoints: List[dict]
strava_activity_stream_id: int | None = None
hr_zone_percentages: dict | None = None

class Config:
"""
Pydantic configuration class enabling ORM mode for model serialization.

Attributes:
orm_mode (bool): When set to True, allows Pydantic models to read data from ORM objects.
"""
orm_mode = True
8 changes: 6 additions & 2 deletions backend/app/strava/activity_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,12 @@ def fetch_and_process_activity_laps(
"total_elapsed_time": lap.elapsed_time,
"total_timer_time": lap.moving_time,
8000 "total_distance": lap.distance,
"avg_heart_rate": round(lap.average_heartrate),
"max_heart_rate": round(lap.max_heartrate),
"avg_heart_rate": (
round(lap.average_heartrate) if lap.average_heartrate else None
),
"max_heart_rate": (
round(lap.max_heartrate) if lap.max_heartrate else None
),
"avg_cadence": round(cad_avg) if cad_stream else None,
"max_cadence": round(cad_max) if cad_stream else None,
"avg_power": round(power_avg) if power_stream else None,
Expand Down
3 changes: 2 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "endurain"
version = "0.12.2"
version = "0.13.0"
description = "Endurain API for the Endurain app"
authors = ["João Vitória Silva <8648976+joaovitoriasilva@users.noreply.github.com>"]
readme = "README.md"
Expand Down Expand Up @@ -39,6 +39,7 @@ user-agents = "^2.2.0"
pydantic = {extras = ["email"], version = "^2.11.3"}



[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
10 changes: 10 additions & 0 deletions frontend/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@fortawesome/vue-fontawesome": "^3.0.8",
"bootstrap": "^5.3.3",
"chart.js": "^4.4.6",
"chartjs-plugin-datalabels": "^2.2.0",
"flag-icons": "^7.2.3",
"leaflet": "^1.9.4",
"luxon": "^3.5.0",
Expand Down
Loading
0