feat: improve history overview visualization and data handling
- Added `safe_float` utility to enhance float handling in correlation calculations, preventing potential errors. - Refactored lag correlation logic in `get_history_overview_viz_bundle` to utilize absolute values safely, improving accuracy in metric comparisons. - Enhanced nutrition body merge logic to ensure proper date handling and data integrity, optimizing the retrieval of nutrition and weight logs. - Introduced new functions in the frontend for processing lag details, improving the visualization of correlation data in the History page.
This commit is contained in:
1 parent
3106ebedae
commit
0365d9eb52
3 files changed
+128
-13
No files matched your search
@@ -13,6 +13,7 @@ from data_layer.correlations import calculate_lag_correlation, calculate_top_dri
|
||||
from data_layer.fitness_viz import get_fitness_dashboard_viz_bundle
|
||||
from data_layer.nutrition_viz import get_nutrition_history_viz_bundle
|
||||
from data_layer.recovery_viz import get_recovery_dashboard_viz_bundle
|
||||
from data_layer.utils import safe_float
|
||||
|
||||
|
||||
def _take_kpis(tiles: Any, max_n: int = 4) -> List[Dict[str, Any]]:
|
||||
@@ -90,11 +91,9 @@ def get_history_overview_viz_bundle(profile_id: str, days: int) -> Dict[str, Any
|
||||
c3_rhr = calculate_lag_correlation(profile_id, "load", "rhr", 14)
|
||||
c3 = None
|
||||
if c3_hrv and c3_rhr:
|
||||
c3 = (
|
||||
c3_hrv
|
||||
if abs(float(c3_hrv.get("correlation") or 0)) >= abs(float(c3_rhr.get("correlation") or 0))
|
||||
else c3_rhr
|
||||
)
|
||||
a1 = abs(safe_float(c3_hrv.get("correlation"), 0.0))
|
||||
a2 = abs(safe_float(c3_rhr.get("correlation"), 0.0))
|
||||
c3 = c3_hrv if a1 >= a2 else c3_rhr
|
||||
if c3 is c3_hrv:
|
||||
c3 = dict(c3)
|
||||
c3["metric"] = "HRV"
|
||||
|
||||
Reference in new issue
Block a user