feat: update app version to 0.9s and enhance body history visualization
Deploy Development / deploy (push) Successful in 56s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Bumped application version to 0.9s and updated changelog with new features.
- Introduced `_weight_trend_kpi` function to analyze weight trends and provide verdicts based on historical data.
- Updated `get_body_history_viz_bundle` to include the new weight trend KPI, improving insights on weight changes.
- Refactored the History component to utilize the new trend KPI, enhancing user experience with clearer weight trend interpretations.
This commit is contained in:
Lars committed 2026-04-20 14:47:22 +02:00
1 parent ba2bd3a4a2
commit da1e0410cc
3 files changed
+89 -122

No files matched your search

+26
View File
@@ -48,6 +48,31 @@ def _iso(d: Any) -> Optional[str]:
return str(d)[:10]
def _weight_trend_kpi(trend_periods: List[Dict[str, Any]]) -> Dict[str, str]:
"""
Kurzurteil Gewichtstrend (Schwelle ±0,25 kg, Priorität 90T → 30T → erste Periode).
Eine Quelle mit dem Verlauf-Bundle — kein paralleles Frontend-Routing mehr.
"""
if not trend_periods:
return {"verdict": "Stabil", "status": "good"}
t90 = next((t for t in trend_periods if t.get("label") == "90T"), None)
t30 = next((t for t in trend_periods if t.get("label") == "30T"), None)
d: Optional[float] = None
if t90 is not None and t90.get("diff_kg") is not None:
d = float(t90["diff_kg"])
elif t30 is not None and t30.get("diff_kg") is not None:
d = float(t30["diff_kg"])
elif trend_periods[0].get("diff_kg") is not None:
d = float(trend_periods[0]["diff_kg"])
else:
return {"verdict": "Stabil", "status": "good"}
if d < -0.25:
return {"verdict": "Trend ↓", "status": "good"}
if d > 0.25:
return {"verdict": "Trend ↑", "status": "warn"}
return {"verdict": "Stabil", "status": "good"}
def get_body_history_viz_bundle(profile_id: str, days: int) -> Dict[str, Any]:
"""
Returns chart-ready series and interpretation tiles for the body history tab.
@@ -437,6 +462,7 @@ def get_body_history_viz_bundle(profile_id: str, days: int) -> Dict[str, Any]:
"min_kg": min_w,
"max_kg": max_w,
"trend_periods": trend_periods,
"trend_kpi": _weight_trend_kpi(trend_periods),
"data_points": len(w_points),
"related_placeholder_keys": [
"weight_aktuell",