Skip to content

refactor: pure domain/calc calculators (DRY stats consolidation) - #3

Merged
jdluu merged 1 commit into
mainfrom
refactor/stats-core
Aug 26, 2026
Merged

refactor: pure domain/calc calculators (DRY stats consolidation)#3
jdluu merged 1 commit into
mainfrom
refactor/stats-core

Conversation

@jdluu

@jdluu jdluu commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the refactor plan.

  • Extracts every volume / streak / duration / training-load / recovery-score / PR calculation into six pure calculator objects under domain/calc/ - no Android imports, no coroutines, trivially testable
  • Single source of truth for the math previously duplicated across StatsRepositoryImpl, StatsCalculator, and three UI composable files
  • Net −250 LOC in existing files; +458 documented LOC of calculators

Test Plan

  • All 165 pre-existing characterization tests pass UNCHANGED (git diff shows zero modifications under app/src/test outside new files) - this proves no behavior change
  • 103 new calculator tests added; suite now 268 tests, 0 failures
  • ./gradlew lintDebug assembleDebug exit 0, 0 lint errors
  • CI green on this PR

Consolidate duplicated stats/training-load/recovery math into six pure,
Android-free calculator objects: VolumeCalculator, DurationCalculator,
StreakCalculator, TrainingLoadCalculator, RecoveryScoreCalculator,
PersonalRecordCalculator.

- StatsRepositoryImpl, StatsCalculator, CalculateTrainingLoadUseCase,
  CompareRoutineSessionsUseCase, DashboardViewModel and the UI *Stats
  composables now delegate to the shared calculators
- StatsCalculator becomes a thin delegation facade (its API is pinned
  by characterization tests)
- Add 103 new unit tests for the calculators; all 165 existing
  characterization tests pass unchanged, proving behavior preservation
@jdluu
jdluu merged commit 0fb4a35 into main Aug 26, 2026
3 checks passed
@jdluu
jdluu deleted the refactor/stats-core branch August 26, 2026 02:54
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.

1 participant