You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ai-plans/2026-07-01-apple-health-xml-workout-import.html
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,7 @@ <h3>Storage is ready</h3>
133
133
<sectionclass="ok">
134
134
<h2>Real Export Findings</h2>
135
135
<p>
136
-
The unpacked export at <code>/Users/dzarlax/Downloads/apple_health_export/</code> was inspected on 2026-07-01.
136
+
A local unpacked Apple Health export at <code><LOCAL_APPLE_HEALTH_EXPORT_DIR>/</code> was inspected on 2026-07-01.
137
137
Only structural counts and attribute shapes were used; implementation should not bake in personal paths or source names.
138
138
</p>
139
139
<ul>
@@ -182,7 +182,7 @@ <h2>Proposed Design</h2>
182
182
<h2>Workout Field Mapping</h2>
183
183
<ul>
184
184
<li><code>external_id</code>: prefer <code>HKMetadataKeySyncIdentifier</code>, then <code>HKExternalUUID</code>; fall back to a deterministic hash from type/start/end/source/duration/statistics when Apple exports lack IDs.</li>
185
-
<li><code>name</code>: map <code>workoutActivityType</code> suffix into readable names such as <code>Outdoor Run</code>, <code>Outdoor Cycle</code>, <code>Walking</code>. Unknown values keep a readable suffix rather than failing import.</li>
185
+
<li><code>name</code>: map <code>workoutActivityType</code> suffix into readable names such as <code>Outdoor Run</code>, <code>Outdoor Cycling</code>, <code>Walking</code>. Unknown values keep a readable suffix rather than failing import.</li>
186
186
<li><code>start_time</code>, <code>end_time</code>: parse Apple Health XML timestamps with the existing HealthKit layout.</li>
187
187
<li><code>duration_sec</code>: use <code>duration</code> plus <code>durationUnit</code> when present; otherwise compute from start/end.</li>
188
188
<li><code>energy_kcal</code>: parse nested <code>WorkoutStatistics type="HKQuantityTypeIdentifierActiveEnergyBurned"</code> using <code>sum</code> and <code>unit</code>.</li>
@@ -309,7 +309,7 @@ <h2>Verification Run</h2>
309
309
<li><code>env GOCACHE=/tmp/health-go-build-cache go test ./internal/applehealth -count=1</code> passed.</li>
310
310
<li><code>env GOCACHE=/tmp/health-go-build-cache go test ./internal/applehealth ./internal/health -count=1</code> passed.</li>
311
311
<li><code>env GOCACHE=/tmp/health-go-build-cache go test ./cmd/import ./internal/handler ./internal/storage ./internal/ui -run "Workout|AppleHealth|ParseXML|Import" -count=1</code> passed.</li>
312
-
<li><code>env GOCACHE=/tmp/health-go-build-cache go run ./cmd/import --file /Users/dzarlax/Downloads/apple_health_export/export.xml --dry-run --batch 100000 --pause 0</code> parsed <code>6,803,675</code> metric points and <code>862</code> workouts in 24 seconds, with no DB writes.</li>
312
+
<li><code>env GOCACHE=/tmp/health-go-build-cache go run ./cmd/import --file /path/to/apple_health_export/export.xml --dry-run --batch 100000 --pause 0</code> parsed <code>6,803,618</code> metric points and <code>862</code> workouts in 24 seconds, with no DB writes.</li>
313
313
<li><code>env GOCACHE=/tmp/health-go-build-cache make test-unit</code> passed.</li>
314
314
</ul>
315
315
</section>
@@ -324,6 +324,21 @@ <h2>Known Limitations After Implementation</h2>
324
324
</ul>
325
325
</section>
326
326
327
+
<sectionclass="ok">
328
+
<h2>PR Review Follow-Up</h2>
329
+
<p>
330
+
Addressed review feedback on 2026-07-03 after PR creation.
331
+
</p>
332
+
<ul>
333
+
<li>Applied the existing physiological quality gate to mapped XML quantity records, so impossible zero values such as heart rate are dropped while valid zero values such as walking asymmetry are preserved.</li>
334
+
<li>Mapped XML cycling workouts to canonical <code>Indoor Cycling</code> / <code>Outdoor Cycling</code> names to match existing exact-name filters.</li>
335
+
<li>Changed Admin import status counter reads to <code>atomic.LoadInt64</code> to match atomic writers.</li>
336
+
<li>Redacted local machine paths from this plan and kept dry-run examples portable.</li>
337
+
<li>Added validation/canonical-name tests for <code>parseWorkout</code> and kept duration-minute handling explicit.</li>
338
+
<li>Cleaned up small review nits: batch flag help text and standard-library <code>math.Abs</code> in unit tests.</li>
0 commit comments