Skip to content

fix(health): aggregate steps + active calories as daily snapshots, not sums + refreshed screenshots#37

Merged
rwlove merged 1 commit into
mainfrom
fix/cumulative-snapshot-aggregation
Jun 10, 2026
Merged

fix(health): aggregate steps + active calories as daily snapshots, not sums + refreshed screenshots#37
rwlove merged 1 commit into
mainfrom
fix/cumulative-snapshot-aggregation

Conversation

@rwlove

@rwlove rwlove commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

While generating screenshots for the prior fixes I caught a real data bug. The Android bridge reports steps and active_calories as cumulative daily-total snapshots — same midnight start_time, re-pushed through the day with a growing end_time. Since dedup keys on end_time, every snapshot persists, and the previous per-day SUM multiplied the real total by the number of snapshots.

Verified against the live store:

Day Metric Real (daily total) Old (summed)
2026-06-08 steps 4,607 40,674 (~9×)
2026-06-10 steps ("today") 330 725
2026-06-08 active calories 263 ~1,315

Fix

Aggregate per (day, start_time) taking the MAX, then sum across distinct start_times per day. Correct for both:

  • re-reported daily snapshots (one start ⇒ the final running total), and
  • genuine sub-day intervals (distinct starts ⇒ summed).

This fixes the long-standing steps inflation and keeps the new active-calories series honest. New tests cover both shapes (TestAggregateHealthCumulativeSnapshots, TestAggregateHealthDistinctIntervalsSum).

Screenshots

All assets/*.png regenerated at 1280×900 from a live-data preview (deep-sleep stages render, Resting HR populated via the min proxy, Active Calories tile + chart, corrected step counts). Added screenshot-stats-balance.png for the new Sets/Volume toggle; README table updated.

🤖 Generated with Claude Code

…t sums

Verified against the live store: the bridge reports steps and active_calories
as cumulative daily-total snapshots — same midnight start_time, re-pushed
through the day with a growing end_time. Because dedup keys on end_time, every
snapshot persists, and the old per-day SUM multiplied the real total by the
number of snapshots:

  2026-06-08 steps: real 4,607 -> summed 40,674 (~9x)
  2026-06-10 steps ("today"): real 330 -> summed 725
  2026-06-08 active calories: real 263 -> summed ~1,315

Aggregate per (day, start_time) taking the MAX, then sum across distinct
start_times per day. Correct for both re-reported daily snapshots (one start ⇒
final total) and genuine sub-day intervals (distinct starts ⇒ summed). Fixes
the long-standing steps inflation and keeps the new active-calories series
honest. Tests cover both shapes.

Also regenerates all assets/ screenshots at 1280×900 from a live-data preview
(deep-sleep stages now render, Resting HR populated via the min proxy, Active
Calories tile + chart, corrected steps) and adds a Muscle Balance screenshot
for the new Sets/Volume toggle. README screenshot table updated to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rwlove rwlove merged commit ad4afa9 into main Jun 10, 2026
3 checks passed
@rwlove rwlove deleted the fix/cumulative-snapshot-aggregation branch June 10, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant