Skip to content

feat(health): add weekly training summaries from parsed workouts - #37

Merged
johnnyhuy merged 1 commit into
mainfrom
agent/issue-36-weekly-training-summaries
Nov 10, 2026
Merged

johnnyhuy merged 1 commit into
mainfrom
agent/issue-36-weekly-training-summaries

Conversation

@johnnyhuy

@johnnyhuy johnnyhuy commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Adds WeeklyTrainingSummary and HealthExport.weeklyTrainingSummaries(calendar:) to aggregate parsed workouts by calendar week, sorted by week start. Summaries include workout and activity counts, normalised duration, energy and distance totals, mean per-workout average heart rate and highest maximum heart rate. Missing metrics remain nil and undated workouts are skipped. The core package remains UI-independent.

Part of #7. Part of #6.
Closes #36.

Verification on commit 6719b9b810fd944430ec65551059fcf8fb8c3c1d

  • mise run lint ran and failed with the existing baseline of 503 violations, including 11 serious, in 130 files. Neither added file has lint violations. No unrelated lint fixes are included.
  • mise run build passed.
  • mise run test passed the 23 video-pipeline smoke checks and 151 XCTest tests plus 10 Swift Testing tests with zero failures.
  • GitHub CI passed SwiftPM build and tests, the iOS build, iOS UI tests with coverage, and mobile e2e. All security checks passed too. The iOS gates were verified through CI rather than repeated locally for this core-only slice.
  • git diff --check origin/main...HEAD passed.

Proof from the local unit-test transcript

==> summary: 23 passed, 0 failed
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testActivityCounts]' passed (0.002 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testAverageAndMaximumHeartRate]' passed (0.001 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testCodableRoundTrip]' passed (0.002 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testEmptyExportReturnsNoSummaries]' passed (0.000 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testGroupsWorkoutsByWeekAndSorts]' passed (0.002 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testMissingMetricsStayNil]' passed (0.001 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testSumsDurationEnergyAndDistanceWithNormalisation]' passed (0.005 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testWeeklySummariesFromParsedExport]' passed (0.001 seconds).
Test Case '-[BetterFitTests.WeeklyTrainingSummaryTests testWorkoutsWithoutStartDateAreSkipped]' passed (0.000 seconds).
	 Executed 151 tests, with 0 failures (0 unexpected) in 2.512 (2.668) seconds
	 Executed 151 tests, with 0 failures (0 unexpected) in 2.512 (2.671) seconds
􁁛  Test run with 10 tests in 1 suite passed after 0.002 seconds.

The nine new tests cover week grouping and sorting, normalised totals, missing metrics, heart rate aggregation, activity counts, empty input, skipping undated workouts, XML parsing through aggregation and Codable round trips.

Average heart rate is deliberately the unweighted mean of per-workout averages, as documented on the field. Recommendation and recovery integration, UI and weekly file export remain future slices under the parent epics. Parent epics #7 and #6 remain open.

Nothing user-facing changed. Unit-test transcript evidence succeeded; no simulator screenshot applies.

@johnnyhuy
johnnyhuy merged commit 1203e4e into main Nov 10, 2026
10 checks passed
@johnnyhuy
johnnyhuy deleted the agent/issue-36-weekly-training-summaries branch November 10, 2026 17:08
This was referenced Nov 10, 2026
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 weekly training summaries aggregated from parsed workouts

1 participant