Fix sleep score parsing, dashboard body battery, segment direction
- Garmin sync: read sleepScores from dailySleepDTO (Garmin nests it there), so sleep score is actually stored instead of always null - Dashboard: pass YYYY-MM-DD to the intraday endpoint (was a full ISO timestamp), so the body-battery tile populates - Segment matching: follow the segment in its created direction with a path-length sanity check, so out-and-back routes no longer match an early start pass to a late finish (the >1h bogus segment times) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -555,8 +555,10 @@ def _parse_day(stats, sleep_data, hrv_data) -> dict:
|
||||
if spo2 and 50 < float(spo2) <= 100:
|
||||
row["spo2_avg"] = float(spo2)
|
||||
|
||||
# Sleep score — structure varies across firmware
|
||||
scores = sleep_data.get("sleepScores") or sleep_data.get("sleepScore")
|
||||
# Sleep score — Garmin nests it under dailySleepDTO.sleepScores on most
|
||||
# firmware, but some return it at the top level; check both.
|
||||
scores = (dto.get("sleepScores") or sleep_data.get("sleepScores")
|
||||
or dto.get("sleepScore") or sleep_data.get("sleepScore"))
|
||||
if isinstance(scores, dict):
|
||||
overall = scores.get("overall") or scores.get("qualityScore")
|
||||
if isinstance(overall, dict):
|
||||
|
||||
Reference in New Issue
Block a user