Skip to content

feat(health): add daily health summaries aggregated from records - #33

Open
johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-32-daily-health-summaries
Open

johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-32-daily-health-summaries

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

Adds daily aggregation for Apple Health exports. A new Foundation-only DailyHealthSummary value type holds one day of steps, active and basal energy, distance, average and resting heart rate, body mass, and sleep duration, and HealthExport.dailySummaries(calendar:) groups the parsed records by start-of-day and returns summaries sorted by day.

Part of #6. Closes #32.

How it was verified:

  • mise run lint - no violations in the added files. Repo total stays at the pre-existing baseline (503 violations, 11 serious across 126 files, all in existing files). The lint task reports failure on that baseline, same as on origin/main before this change.
  • mise run build - passed.
  • mise run test - passed, 133 tests with 0 failures. The 9 new DailyHealthSummaryTests are listed below.
  • mise run ios:build:dev and mise run ios:test:ui were not run. Nothing user-facing changed; this slice is core aggregation logic only.

Proof, terminal capture from mise run test filtered to the new suite:

Test Case '-[BetterFitTests.DailyHealthSummaryTests testAverageHeartRateAndLatestRestingAndMass]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testCodableRoundTrip]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testDailySummariesFromParsedExport]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testEmptyExportReturnsNoSummaries]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testGroupsRecordsByDayAndSorts]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testMissingKindsStayNil]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testRecordsWithoutStartDateAreSkipped]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testSleepDurationSumsStagesStartingThatDay]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testSumsStepsEnergyAndDistanceWithNormalisation]' passed.
Executed 133 tests, with 0 failures (0 unexpected)

Each test name states what it shows. Together they cover grouping and sorting by day, summing steps with kilojoule and kilometre normalisation, averaging heart rate, picking the latest resting heart rate and body mass of the day, summing sleep stages, keeping missing kinds nil instead of zero, skipping records without a start date, an empty export, an end-to-end run through HealthExportParser, and a Codable round-trip.

Reviewer notes:

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.

Add daily health summaries aggregated from HealthRecord

1 participant