Skip to content

feat(health): parse top-level Records from Apple Health export - #31

Merged
johnnyhuy merged 1 commit into
mainfrom
agent/issue-30-health-records
Nov 8, 2026
Merged

johnnyhuy merged 1 commit into
mainfrom
agent/issue-30-health-records

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

Adds top-level Record parsing for Apple Health exports. A new Foundation-only HealthRecord model captures step count, heart rate, resting heart rate, active and basal energy, distance, body mass, and sleep analysis records, and HealthExportParser now returns them through parseRecords and a combined parseExport alongside the existing workout parsing.

Part of #6. Closes #30.

How it was verified:

  • mise run lint - no violations in the added or changed files. Repo total stays at the pre-existing baseline (503 violations, 11 serious across 124 files, all in existing app files).
  • mise run build - passed.
  • mise run test - passed, 124 tests with 0 failures. The 14 new HealthRecordTests 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 parsing logic only.

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

Test Case '-[BetterFitTests.HealthRecordTests testBodyMassInKilogramsAndPounds]' passed (0.003 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testCodableRoundTrip]' passed (0.002 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testDistanceNormalisationFromMiles]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testEmptyExportReturnsNoRecords]' passed (0.000 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testEnergyNormalisationFromKilojoules]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testMalformedXMLThrowsForRecords]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testNormalisedValuesNilForWrongKind]' passed (0.000 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testParseExportReturnsWorkoutsAndRecordsTogether]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testParsesTopLevelRecords]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testParseWorkoutsStillSkipsRecordsAsWorkouts]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testPreservesUnknownRecordType]' passed (0.000 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testQuantityRecordHasNoCategoryValue]' passed (0.001 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testRecordsFromDataAPI]' passed (0.002 seconds).
Test Case '-[BetterFitTests.HealthRecordTests testSleepRecordKeepsCategoryValueAndDuration]' passed (0.001 seconds).
Executed 14 tests, with 0 failures (0 unexpected) in 0.014 (0.015) seconds
Executed 124 tests, with 0 failures (0 unexpected) in 1.986 (1.997) seconds

Each test name states what it shows. Together they cover parsing six records from a mixed export, keeping sleep category values as strings with a derived duration, returning workouts and records together from parseExport, keeping the existing parseWorkouts behaviour unchanged, normalising kilojoules, miles, and pounds, returning nil normalised values for the wrong kind, preserving unknown record types, handling an empty export, throwing on malformed XML, the Data-based API, and a Codable round-trip.

Reviewer notes:

Co-authored-by: Muse Code <muse-code@meta.com>
@johnnyhuy
johnnyhuy merged commit f74c050 into main Nov 8, 2026
10 checks passed
@johnnyhuy
johnnyhuy deleted the agent/issue-30-health-records branch November 8, 2026 03:33
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.

Parse top-level Health Records (steps, heart rate, sleep, weight) from Apple Health export

1 participant