Skip to content

Add strength/stretching workouts - #16

Open
rbro112 wants to merge 1 commit into
mainfrom
ryan/add_strength_stretching_workouts
Open

Add strength/stretching workouts#16
rbro112 wants to merge 1 commit into
mainfrom
ryan/add_strength_stretching_workouts

Conversation

@rbro112

@rbro112 rbro112 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

}

if (item.discipline === 'strength') {
return (item.sets ?? 1) * (item.reps ?? 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The getWeight function incorrectly defaults to a weight of 1 for strength workouts when sets and reps are missing, instead of 0.
Severity: MEDIUM

Suggested Fix

Modify the nullish coalescing operator's default value from 1 to 0 for both sets and reps within the getWeight function. The calculation should be return (item.sets ?? 0) * (item.reps ?? 0); to ensure a missing value results in a weight of 0.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/workouts/workout-utils.ts#L47

Potential issue: For 'strength' discipline workouts, the `getWeight` function calculates
weight using `(item.sets ?? 1) * (item.reps ?? 1)`. If both `sets` and `reps` are
undefined, which is permitted by the schema, the weight incorrectly defaults to 1. This
behavior is inconsistent with other workout disciplines, which default to a weight of 0
when their primary metrics are missing. This will cause functions like
`getTotalWeight()` to report inflated values for strength workouts that do not have
specified sets and reps.

Did we get this right? 👍 / 👎 to inform future reviews.

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