-
-
Notifications
You must be signed in to change notification settings - Fork 26
fix: use effective bodyweight load for exercise display and 1RM (#684) #685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fcdc7bb
49a31e3
41f6d84
a5ada65
092d3cc
a27d32d
766c25e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import com.devil.phoenixproject.data.repository.MAX_RECENT_EXERCISE_SESSIONS | |
| import com.devil.phoenixproject.data.repository.VelocityOneRepMaxRepository | ||
| import com.devil.phoenixproject.data.repository.WorkoutRepository | ||
| import com.devil.phoenixproject.domain.model.WorkoutSession | ||
| import com.devil.phoenixproject.domain.model.displayHeaviestKgPerCable | ||
| import com.devil.phoenixproject.util.OneRepMaxCalculator | ||
|
|
||
| enum class CurrentOneRepMaxSource { | ||
|
|
@@ -19,8 +20,8 @@ data class CurrentOneRepMax( | |
| val measuredAt: Long, | ||
| ) | ||
|
|
||
| fun WorkoutSession.estimatedOneRepMaxPerCableOrNull(): Float? { | ||
| val load = weightPerCableKg.takeIf { it.isFinite() && it > 0f } ?: return null | ||
| fun WorkoutSession.estimatedOneRepMaxPerCableOrNull(isBodyweight: Boolean = false): Float? { | ||
| val load = displayHeaviestKgPerCable(isBodyweight).takeIf { it > 0f } ?: return null | ||
| val reps = workingReps.takeIf { it > 0 } | ||
| ?: totalReps.takeIf { it > 0 } | ||
| ?: return null | ||
|
|
@@ -36,7 +37,11 @@ class ResolveCurrentOneRepMaxUseCase( | |
| private val assessmentRepository: AssessmentRepository, | ||
| private val workoutRepository: WorkoutRepository, | ||
| ) { | ||
| suspend operator fun invoke(exerciseId: String, profileId: String): CurrentOneRepMax? { | ||
| suspend operator fun invoke( | ||
| exerciseId: String, | ||
| profileId: String, | ||
| isBodyweight: Boolean = false, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the selected exercise is bodyweight, counterweight clamps a session's effective load to zero, and no velocity or assessment result exists, Useful? React with 👍 / 👎. |
||
| ): CurrentOneRepMax? { | ||
| require(exerciseId.isNotBlank()) | ||
| require(profileId.isNotBlank()) | ||
|
|
||
|
|
@@ -79,7 +84,7 @@ class ResolveCurrentOneRepMaxUseCase( | |
| limit = MAX_RECENT_EXERCISE_SESSIONS, | ||
| ).forEach { session -> | ||
| if (session.exerciseId == exerciseId && session.profileId == profileId) { | ||
| val estimate = session.estimatedOneRepMaxPerCableOrNull() | ||
| val estimate = session.estimatedOneRepMaxPerCableOrNull(isBodyweight) | ||
| if (estimate != null) { | ||
| return CurrentOneRepMax( | ||
| perCableKg = estimate, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.