Skip to content

fix(stats): period-aware steps/sleep tiles, sleep hover totals, live Today button#44

Merged
rwlove merged 1 commit into
mainfrom
fix/stats-period-today-button
Jun 25, 2026
Merged

fix(stats): period-aware steps/sleep tiles, sleep hover totals, live Today button#44
rwlove merged 1 commit into
mainfrom
fix/stats-period-today-button

Conversation

@rwlove

@rwlove rwlove commented Jun 25, 2026

Copy link
Copy Markdown
Owner

What

Four reported issues, all frontend-only (no schema change):

  1. Steps avg not updating per periodAvg / day and Best day now compute over the selected Week/Month/Year/All-time window (were hardcoded last-7-days / all-time).
  2. Sleep stats not updating per periodAvg / night and Deep (total deep ÷ total sleep) now compute over the selected period (were last-7-days / last-night only).
  3. Sleep bar hover — index-mode tooltip now shows every stage (Deep/Light/REM/Awake) plus a Total sleep footer.
  4. "Today" button on phonegoToToday() used window._serverDate (baked in at page load), so a phone left open across midnight jumped to yesterday. Now uses the live device date.

Tile labels relabeled: 7-day avg → Avg / day (steps), 7-day avg → Avg / night + Deep (last) → Deep (sleep).

Regenerated screenshot-stats-steps.png and screenshot-stats-sleep.png.

Note

The treadmill cardio event the issue started from was already auto-logged by the MQTT consumer (health_record id 823, 04:39→04:59 EDT, ~19m49s) and shows on Stats → Cardio — no data change needed.

🤖 Generated with Claude Code

…Today button

The Stats wearable tiles for Steps and Sleep showed fixed windows that
ignored the selected period: steps "7-day avg" and sleep "7-day avg" /
"Deep (last)" never changed when switching Week/Month/Year/All-time even
though the charts did.

- Steps: "Avg / day" and "Best day" now compute over the selected period.
- Sleep: "Avg / night" and "Deep" (total deep ÷ total sleep) now compute
  over the selected period.
- Sleep chart hover now uses index mode: hovering a night shows every
  stage (Deep/Light/REM/Awake) plus a "Total sleep" footer.
- Relabel tiles accordingly (7-day avg → Avg / day, Avg / night; Deep
  (last) → Deep).

Also fix the main page "Today" button: goToToday() used
window._serverDate, which is rendered server-side at page load, so a
phone left open across midnight sent "Today" to yesterday. It now
computes the live device date (en-CA YYYY-MM-DD).

Regenerated assets/screenshot-stats-steps.png and -sleep.png for the new
labels. Frontend-only; no schema change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@rwlove rwlove merged commit 441c5c0 into main Jun 25, 2026
3 checks passed
@rwlove rwlove deleted the fix/stats-period-today-button branch June 25, 2026 15:35
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