feat: enhance recovery dashboard with vital signs analytics and visualization improvements
- Updated the `build_vital_signs_matrix_chart_payload` function to accept optional keys for omitting specific snapshot data, improving flexibility in data presentation. - Enhanced the `build_recovery_dashboard_kpi_tiles` function to conditionally merge heart and autonomic tiles based on new parameters, refining the dashboard's insights. - Integrated new analytics features in the `RecoveryDashboardOverview` component, including consolidated paragraphs for better narrative context and visual representation of trends. - Improved the handling of vital signs data in the frontend, ensuring clearer messaging and enhanced user experience when displaying vital metrics.
This commit is contained in:
1 parent
e7bcdc3228
commit
8cb5ad992f
7 files changed
+299
-166
No files matched your search
@@ -7,7 +7,7 @@ Ausgelagert aus routers/charts.py (Issue 53 / Layer 1).
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict, Optional, Set
|
||||
|
||||
from db import get_db, get_cursor
|
||||
from data_layer.recovery_metrics import (
|
||||
@@ -396,8 +396,15 @@ def _tone_to_bar_value(tone: str) -> float:
|
||||
return {"good": 88.0, "warn": 52.0, "bad": 22.0, "neutral": 62.0}.get(tone, 55.0)
|
||||
|
||||
|
||||
def build_vital_signs_matrix_chart_payload(profile_id: str, days: int) -> Dict[str, Any]:
|
||||
"""Letzte Messungen im Fenster; sonst Fallback auf jüngste Messung überhaupt (Issue 53 / Layer 1)."""
|
||||
def build_vital_signs_matrix_chart_payload(
|
||||
profile_id: str,
|
||||
days: int,
|
||||
omit_snapshot_keys: Optional[Set[str]] = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""Letzte Messungen im Fenster; sonst Fallback auf jüngste Messung überhaupt (Issue 53 / Layer 1).
|
||||
|
||||
omit_snapshot_keys: z. B. {'resting_hr','hrv'} wenn dieselbe Einordnung bereits im Vital-Verlauf steht.
|
||||
"""
|
||||
if days < 7:
|
||||
days = 7
|
||||
if days > 365:
|
||||
@@ -464,7 +471,11 @@ def build_vital_signs_matrix_chart_payload(profile_id: str, days: int) -> Dict[s
|
||||
if bp_row:
|
||||
bp_for_items = {"systolic": bp_row.get("systolic"), "diastolic": bp_row.get("diastolic")}
|
||||
|
||||
items = build_vital_items_from_rows(vitals_for_items, bp_for_items)
|
||||
items = build_vital_items_from_rows(
|
||||
vitals_for_items, bp_for_items, omit_keys=omit_snapshot_keys
|
||||
)
|
||||
if not items and vitals_for_items and omit_snapshot_keys:
|
||||
items = build_vital_items_from_rows(vitals_for_items, bp_for_items, omit_keys=None)
|
||||
|
||||
if not items:
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user