Repository navigation
feat(measurements): import Apple workout effort and physical effort - #1416
camiracode wants to merge 3 commits into
Conversation
|
@camiracode Thanks, this is a careful piece of work. A few things before it can go in:
I'll merge it by hand afterwards so the branch name doesn't end up in the history. |
The logged workout-effort score and the watch's estimate are separate types, so a day mean of one cannot blend the other. Physical effort is its own rate in kcal/(hr·kg), never added to energy. Migration 0514 adds the three enum values inside a lock-bounded DO block. Co-authored-by: Cambreo, LLC <[email protected]>
723d52d to
9408940
Compare
|
@MBombeck Thanks for the review. All four are addressed: rebased on main (after 0513), migration renamed to |
|
@camiracode Thanks, the rebase and the four points look good. CI ran now and one integration test fails, in
|
PostgreSQL orders an enum column by declaration order, not alphabetically, so the ingest test sorts the stored rows by type name before comparing. Fixes the integration shard 3/4 failure.
|
@camiracode Thanks, the sort fix does it. After 1.48.4 the branch had a one-line conflict in the function-size baseline, so I merged main into it; CI is green now. This goes into the next release together with migration 0514. |
…cores-8f55 # Conflicts: # src/__tests__/baselines/source-function-lines.json
Summary
Apple Health workout effort and physical effort were in the deferred set, so an import skipped them. They are stored as their own measurement types now. The logged workout effort score and the watch’s estimate are separate 0–10 score types, so a day mean never blends them. Physical effort is kept as a rate in kcal/(hr·kg), and is not added to active or resting energy. Existing rows are unchanged.
Type of change
Apple types
HKQuantityTypeIdentifierWorkoutEffortScore(iOS 18)WORKOUT_EFFORT_SCOREscoreHKQuantityTypeIdentifierEstimatedWorkoutEffortScore(iOS 18)ESTIMATED_WORKOUT_EFFORT_SCOREscoreHKQuantityTypeIdentifierPhysicalEffort(iOS 17)PHYSICAL_EFFORTkcal/(hr·kg)The HealthKit unit for the scores is
count. The HealthKit unit for physical effort iskcal/(hr*kg); there is no sibling unit to convert from. Apple’s published effort scale is 1–10. The stored band starts at 0 so a zero is kept, and stops at 10 so a slipped unit is refused.The logged score and the estimate are two types. Samples stay distinct by their own external ids. Neither type is summed into a day total, and neither has a personal-record direction.
Workout effort follows the workouts module. Physical effort stays ungated, like active energy: it is an intensity sample, not a workout session.
CHANGELOG.mdis left out; the release commit writes it.Migration
0514_apple_health_effort(rebased on main after 0513) addsWORKOUT_EFFORT_SCORE,ESTIMATED_WORKOUT_EFFORT_SCOREandPHYSICAL_EFFORTtomeasurement_typewithADD VALUE IF NOT EXISTS, in oneDOblock with the lock-timeout marker. No rows are rewritten. PostgreSQL cannot drop an enum value, so there is no down migration.Test plan
pnpm typecheckpnpm lint(changed sources)pnpm test(unit). Mapping fixture:src/lib/measurements/__tests__/fixtures/apple-health-effort-samples.json.pnpm openapi:generate(spec committed)pnpm test:integration—tests/integration/apple-health-effort-ingest.test.tscovers the batch route,acceptedTypes, a backup round-trip, and out-of-range skips. Not run in the environment that prepared this branch (no Docker).Screenshots (UI changes only)
No screen changes beyond the existing measurement list, charts, and report selection picking up two new activity types.
Checklist
mainbranch (trunk-based — see CONTRIBUTING.md)pnpm typecheckpasses locallypnpm lintpasses locallypnpm testpasses locallypnpm format:checkpasses locallypnpm buildpasses locally (not run for this branch)t("key")with bothmessages/en.jsonandmessages/de.jsonupdated (and the other shipped locales)CHANGELOG.mdif user-visibledocs/integrations/apple-health.mdanddocs/integrations/data-import.mdLinked issues
None.