Skip to content

fix(explore): read sleep efficiency from the daily column as a percentage - #2939

Open
matthiasthomas wants to merge 1 commit into
ryanbr:mainfrom
matthiasthomas:fix/sleep-efficiency-percent
Open

matthiasthomas wants to merge 1 commit into
ryanbr:mainfrom
matthiasthomas:fix/sleep-efficiency-percent

Conversation

@matthiasthomas

Copy link
Copy Markdown

What this PR does

Sleep Efficiency reads about "1 %" in Explore and Compare: on strap-only days on macOS/iOS, and on every day whose efficiency is stored as a fraction on Android.

Cause: a sleep_efficiency metricSeries point is WHOOP's 0–100 percentage and the catalogs label the key "%". The daily-column layer underneath returned DailyMetric.efficiency as is, which is normally a 0–1 fraction. On Apple the two scales were mixed in one series, so the average, min/max, delta, ring gauge and correlation scan took both. Android's CSV importer writes no such series, so every day came from the column.

Fix: dailyColumn returns a percentage on both platforms. The column is not uniformly a fraction (the Fitbit, Oura-export and Mi Band importers and the demo seeders write a percentage), so a bare * 100 would show 8900 %. Values above 1.5 pass through, the same split the existing efficiency heal migrations use.

Scope:

  • Android's Compare and Explore kept their own column maps. Both now go through dailyColumn.
  • Stored data is unchanged.
  • The importers that write a percentage are a separate change.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • CI / tooling

How it was tested

  • New tests: SleepEfficiencyUnitTests (Swift) and SleepEfficiencyUnitTest (Kotlin) cover mixed imported and strap-only days, a percentage-scale row, and 19 values whose expected results are the stdout of the Swift expression compiled standalone. SleepEfficiencyCallSiteAuditTest checks that Android's two screens do not read the raw column.
  • Without the fix: the new tests fail on both platforms. With it they pass.
  • Full StrandTests (macOS): 2,270 tests. The only failures are the two timezone tests fix(dates): show day-keyed dates on their own day in every time zone #2723 fixes; they also fail without this change. NOOPiOS builds.
  • Full testFullDebugUnitTest: 6,641 tests, 2 failures, both in RecoveryDriversTest, which also fail locally without this change.
  • Checks: doc-comment lint, i18n audit, parity ledger and ratchet pass.
  • Not verified: not tried in a running app. No BLE path is touched.

Checklist

  • Swift package tests pass for any package I touched (swift test in Packages/<name>): n/a, no package touched
  • Android unit tests pass if I touched android/: all but the 2 RecoveryDriversTest failures above
  • No new build warnings introduced
  • UI changes use only StrandDesign tokens: n/a, no styling change
  • No hardcoded hex frame bytes; protocol facts live in the schema / decoders
  • Follows the conventions in docs/CONTRIBUTING.md
  • I did not commit generated output (Strand.xcodeproj/) or any secrets/keystores

Related issues

None found.

🤖 Generated with Claude Code

…tage

A sleep_efficiency metricSeries point is WHOOP's 0-100 percentage and the
catalogs label the key "%", but the daily-column layer under it returned
DailyMetric.efficiency, normally a 0-1 fraction. Days the series does not
cover read about "1 %", next to imported days in the 90s on Apple and for
every day on Android, whose importer writes no such series. Averages,
deltas, the ring gauge and the correlation scan took both scales.

dailyColumn now returns a percentage on both platforms. The column is not
uniformly a fraction (the Fitbit, Oura-export and Mi Band importers and the
demo seeders write a percentage), so values above 1.5 pass through, the same
split the existing efficiency heal migrations use. Android's Compare and
Explore column maps go through dailyColumn instead of the raw column.
Stored data is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
n1c pushed a commit to n1c/noop that referenced this pull request Nov 26, 2026
…om the daily column as a percentage

ryanbr#2939

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZyrZuBf2575a3s8MZTqNZ
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