feat: enhance recovery dashboard with optional average sleep KPI and structured insights
- Added an `include_avg_sleep_kpi` parameter to the `build_recovery_dashboard_kpi_tiles` function to conditionally include average sleep data in the dashboard. - Updated the `get_recovery_dashboard_viz_bundle` function to pass the new parameter, ensuring flexibility in data presentation. - Refactored the insights generation in the `vitals_fitness_insights.py` file to utilize a new structured approach for better organization of heart and VO2 insights. - Introduced new components in the frontend for displaying insights, improving the user experience and clarity of vital metrics.
This commit is contained in:
1 parent
857cc1043a
commit
61738cecb7
4 files changed
+291
-258
No files matched your search
@@ -42,6 +42,7 @@ def build_recovery_dashboard_kpi_tiles(
|
||||
hrv_vs_baseline_pct: Optional[float],
|
||||
rhr_vs_baseline_pct: Optional[float],
|
||||
merge_heart_autonomic_tiles: bool = True,
|
||||
include_avg_sleep_kpi: bool = True,
|
||||
) -> List[Dict[str, Any]]:
|
||||
tiles: List[Dict[str, Any]] = []
|
||||
|
||||
@@ -79,20 +80,21 @@ def build_recovery_dashboard_kpi_tiles(
|
||||
}
|
||||
)
|
||||
|
||||
tiles.append(
|
||||
{
|
||||
"key": "avg_sleep",
|
||||
"category": "Ø Schlafdauer",
|
||||
"icon": "🌙",
|
||||
"value": f"{avg_sleep_hours:.1f} h".replace(".", ",") if avg_sleep_hours is not None else "—",
|
||||
"sublabel": "Im gewählten Fenster",
|
||||
"status": "good" if avg_sleep_hours and avg_sleep_hours >= 7 else "warn",
|
||||
"verdict": "Gut" if avg_sleep_hours and avg_sleep_hours >= 7 else "Hinweis",
|
||||
"hoverTop": "Durchschnittliche Schlafdauer",
|
||||
"hoverBody": "get_sleep_duration_data",
|
||||
"keys": ["sleep_duration_avg"],
|
||||
}
|
||||
)
|
||||
if include_avg_sleep_kpi:
|
||||
tiles.append(
|
||||
{
|
||||
"key": "avg_sleep",
|
||||
"category": "Ø Schlafdauer",
|
||||
"icon": "🌙",
|
||||
"value": f"{avg_sleep_hours:.1f} h".replace(".", ",") if avg_sleep_hours is not None else "—",
|
||||
"sublabel": "Im gewählten Fenster",
|
||||
"status": "good" if avg_sleep_hours and avg_sleep_hours >= 7 else "warn",
|
||||
"verdict": "Gut" if avg_sleep_hours and avg_sleep_hours >= 7 else "Hinweis",
|
||||
"hoverTop": "Durchschnittliche Schlafdauer",
|
||||
"hoverBody": "get_sleep_duration_data",
|
||||
"keys": ["sleep_duration_avg"],
|
||||
}
|
||||
)
|
||||
|
||||
if merge_heart_autonomic_tiles and (
|
||||
hrv_vs_baseline_pct is not None or rhr_vs_baseline_pct is not None
|
||||
|
||||
Reference in new issue
Block a user