Skip to content

Commit db2f2be

Browse files
tomkisclaude
andcommitted
fix: handle missing historical result for custom mode in getWorkoutStats
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 07b2da5 commit db2f2be

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

mobile/domain/aggregate/mesocycle.aggregate-root.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,18 @@ export class MesocycleAggregateRoot {
565565
})
566566
.with({ state: WorkoutExerciseState.pending }, pendingExercise => {
567567
const historicalResult = historicalResults.find(result => result.exercise.id === pendingExercise.exercise.id)
568-
if (!historicalResult) {
569-
throw new Error('Historical result not found')
570-
}
571-
572568
const firstSet = pendingExercise.sets[0]
573-
if (!firstSet) {
574-
throw new Error('First set not found')
569+
570+
if (!historicalResult || !firstSet) {
571+
return {
572+
exercise: pendingExercise.exercise,
573+
sets: pendingExercise.targetSets,
574+
reps: firstSet?.reps ?? null,
575+
weight: firstSet?.weight ?? null,
576+
lastTested1Rm: null,
577+
projected1Rm: null,
578+
exerciseStatus: pendingExercise.progressionType,
579+
}
575580
}
576581

577582
return {

0 commit comments

Comments
 (0)