Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

feat(exercises): add zero-credit muscle overrides

Emil Zapatafef720d2a378
diff --git a/frontend/src/lib/exercise-muscle-batch-1.js b/frontend/src/lib/exercise-muscle-batch-1.js
index deaaefe23..d0a8b5429 100644
--- a/frontend/src/lib/exercise-muscle-batch-1.js
+++ b/frontend/src/lib/exercise-muscle-batch-1.js
@@ -18,7 +18,59 @@ export { MACHINE_BATCH_2 }
* generated batch so a correction can replace a generated body part or muscle list without
* editing generated data. Explicit metadata on a user/custom exercise wins as well.
*/
-export const USER_EXERCISE_MUSCLE_OVERRIDES = Object.freeze({})
+const completeWeights = weights => Object.freeze(weights)
+const overridesFor = (ids, muscleWeights) => Object.fromEntries(
+ ids.map(id => [id, Object.freeze({ muscleWeights })])
+)
+
+const PULL_UP_WEIGHTS = completeWeights({
+ 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, triceps: 0
+})
+const PULLDOWN_WEIGHTS = completeWeights({
+ 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, trapezius: 0.4, triceps: 0
+})
+const L_PULL_UP_WEIGHTS = completeWeights({
+ 'upper-back': 1, abs: 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4,
+ 'hip-flexors': 0.4, triceps: 0
+})
+const T_BAR_ROW_WEIGHTS = completeWeights({
+ 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, trapezius: 0.4,
+ chest: 0, triceps: 0
+})
+const CHEST_PRESS_WEIGHTS = completeWeights({ chest: 1, deltoids: 0.4, triceps: 0.4, biceps: 0 })
+const CLOSE_GRIP_PRESS_WEIGHTS = completeWeights({ triceps: 1, chest: 0.4, deltoids: 0.4, biceps: 0 })
+const CALF_PRESS_WEIGHTS = completeWeights({ calves: 1, hamstring: 0 })
+const CALF_PRESS_QUADRICEPS_WEIGHTS = completeWeights({ calves: 1, quadriceps: 0.4, hamstring: 0 })
+const CALF_PRESS_GLUTEAL_WEIGHTS = completeWeights({ calves: 1, gluteal: 0.4, hamstring: 0 })
+const HIP_ABDUCTION_WEIGHTS = completeWeights({ gluteal: 1, hamstring: 0 })
+const LEG_PRESS_WEIGHTS = completeWeights({
+ quadriceps: 1, gluteal: 1, adductors: 1, hamstring: 0.4, calves: 0
+})
+const SMITH_HACK_SQUAT_WEIGHTS = completeWeights({
+ quadriceps: 1, gluteal: 1, adductors: 1, hamstring: 0.4,
+ 'lower-back': 0.4, abs: 0.4, obliques: 0.4, calves: 0
+})
+const MACHINE_FLY_WEIGHTS = completeWeights({
+ chest: 1, deltoids: 0.4, serratus: 0.4, biceps: 0
+})
+const TRICEPS_EXTENSION_WEIGHTS = completeWeights({ triceps: 1, deltoids: 0 })
+
+export const USER_EXERCISE_MUSCLE_OVERRIDES = Object.freeze({
+ ...overridesFor(['1429', '1432', '0652', '0651', '0017', '0015', '0970', '0841'], PULL_UP_WEIGHTS),
+ ...overridesFor(['1325', '1347', '2330', '2616', '2736', '3563', '0007', '0150', '0153', '0177', '0198', '0197', '0205', '0245', '0579', '0673', '0818'], PULLDOWN_WEIGHTS),
+ ...overridesFor(['3418'], L_PULL_UP_WEIGHTS),
+ ...overridesFor(['1349', '0606'], T_BAR_ROW_WEIGHTS),
+ ...overridesFor(['1254', '1256', '1257', '1299', '1300', '1301', '1479', '2144', '3758', '0025', '0033', '0045', '0047', '0122', '0151', '0169', '0289', '0301', '0314', '0748', '0577', '0576'], CHEST_PRESS_WEIGHTS),
+ ...overridesFor(['0030', '0751'], CLOSE_GRIP_PRESS_WEIGHTS),
+ ...overridesFor(['2289', '2335', '0738'], CALF_PRESS_WEIGHTS),
+ ...overridesFor(['1391'], CALF_PRESS_QUADRICEPS_WEIGHTS),
+ ...overridesFor(['2334', '1392'], CALF_PRESS_GLUTEAL_WEIGHTS),
+ ...overridesFor(['0597', '3006'], HIP_ABDUCTION_WEIGHTS),
+ ...overridesFor(['1425', '1463', '1464', '2287', '2611', '0739', '0741', '0743', '0760'], LEG_PRESS_WEIGHTS),
+ ...overridesFor(['0755'], SMITH_HACK_SQUAT_WEIGHTS),
+ ...overridesFor(['0596'], MACHINE_FLY_WEIGHTS),
+ ...overridesFor(['0607'], TRICEPS_EXTENSION_WEIGHTS),
+})
export function exerciseMuscleMetadataFor(id) {
return {
diff --git a/frontend/src/lib/exercise-muscle-batch-1.test.js b/frontend/src/lib/exercise-muscle-batch-1.test.js
index 8d95486d8..6b00617f3 100644
--- a/frontend/src/lib/exercise-muscle-batch-1.test.js
+++ b/frontend/src/lib/exercise-muscle-batch-1.test.js
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { BODYPARTS, EXDB, EXIDX, registerCustom } from './exercises.js'
-import { COMPOUND_LIFT_BATCH_1 } from './exercise-muscle-batch-1.js'
-import { MUSCLES, musclesOf } from './muscles.js'
+import { COMPOUND_LIFT_BATCH_1, USER_EXERCISE_MUSCLE_OVERRIDES } from './exercise-muscle-batch-1.js'
+import { MUSCLES, musclesOf, muscleWeightsOf } from './muscles.js'
const ids = Object.keys(COMPOUND_LIFT_BATCH_1)
const catalogueIds = new Set(EXDB.map(ex => ex.id))
@@ -83,3 +83,77 @@ describe('compound-lift muscle metadata batch 1', () => {
expect(EXIDX['0025']).toMatchObject(COMPOUND_LIFT_BATCH_1['0025'])
})
})
+
+describe('owner-approved zero-credit overrides', () => {
+ const cases = [
+ [
+ ['1429', '1432', '0652', '0651', '0017', '0015', '0970', '0841'],
+ { 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, triceps: 0 },
+ ],
+ [
+ ['1325', '1347', '2330', '2616', '2736', '3563', '0007', '0150', '0153', '0177', '0198', '0197', '0205', '0245', '0579', '0673', '0818'],
+ { 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, trapezius: 0.4, triceps: 0 },
+ ],
+ [
+ ['3418'],
+ { 'upper-back': 1, abs: 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, 'hip-flexors': 0.4, triceps: 0 },
+ ],
+ [
+ ['1349', '0606'],
+ { 'upper-back': 1, biceps: 0.4, deltoids: 0.4, forearm: 0.4, trapezius: 0.4, chest: 0, triceps: 0 },
+ ],
+ [
+ ['1254', '1256', '1257', '1299', '1300', '1301', '1479', '2144', '3758', '0025', '0033', '0045', '0047', '0122', '0151', '0169', '0289', '0301', '0314', '0748', '0577', '0576'],
+ { chest: 1, deltoids: 0.4, triceps: 0.4, biceps: 0 },
+ ],
+ [['0030', '0751'], { triceps: 1, chest: 0.4, deltoids: 0.4, biceps: 0 }],
+ [['2289', '2335', '0738'], { calves: 1, hamstring: 0 }],
+ [['1391'], { calves: 1, quadriceps: 0.4, hamstring: 0 }],
+ [['2334', '1392'], { calves: 1, gluteal: 0.4, hamstring: 0 }],
+ [['0597', '3006'], { gluteal: 1, hamstring: 0 }],
+ [
+ ['1425', '1463', '1464', '2287', '2611', '0739', '0741', '0743', '0760'],
+ { quadriceps: 1, gluteal: 1, adductors: 1, hamstring: 0.4, calves: 0 },
+ ],
+ [
+ ['0755'],
+ { quadriceps: 1, gluteal: 1, adductors: 1, hamstring: 0.4, 'lower-back': 0.4, abs: 0.4, obliques: 0.4, calves: 0 },
+ ],
+ [['0596'], { chest: 1, deltoids: 0.4, serratus: 0.4, biceps: 0 }],
+ [['0607'], { triceps: 1, deltoids: 0 }],
+ ]
+
+ it.each(cases)('keeps the complete reviewed map for %s', (ids, expected) => {
+ for (const id of ids) {
+ expect(USER_EXERCISE_MUSCLE_OVERRIDES[id]).toEqual({ muscleWeights: expected })
+ expect(EXIDX[id].muscleWeights).toEqual(expected)
+ expect(muscleWeightsOf(EXIDX[id])).toEqual(expected)
+ }
+ })
+
+ it('retains every explicit zero through the runtime catalogue', () => {
+ expect(Object.keys(USER_EXERCISE_MUSCLE_OVERRIDES).sort())
+ .toEqual(cases.flatMap(([ids]) => ids).sort())
+ for (const [id, override] of Object.entries(USER_EXERCISE_MUSCLE_OVERRIDES)) {
+ const zeros = Object.entries(override.muscleWeights).filter(([, weight]) => weight === 0)
+ expect(zeros.length, id).toBeGreaterThan(0)
+ for (const [muscle] of zeros) expect(EXIDX[id].muscleWeights[muscle], `${id}:${muscle}`).toBe(0)
+ }
+ })
+
+ it('retains every positive weight outside the reviewed zero-credit corrections', () => {
+ for (const [id, override] of Object.entries(USER_EXERCISE_MUSCLE_OVERRIDES)) {
+ const withoutOverride = { ...EXIDX[id] }
+ delete withoutOverride.muscleWeights
+ const previousPositive = musclesOf(withoutOverride)
+ const completePositive = { ...override.muscleWeights }
+ for (const [muscle, weight] of Object.entries(override.muscleWeights)) {
+ if (weight === 0) {
+ delete previousPositive[muscle]
+ delete completePositive[muscle]
+ }
+ }
+ expect(completePositive, id).toEqual(previousPositive)
+ }
+ })
+})
diff --git a/frontend/src/lib/muscles.test.js b/frontend/src/lib/muscles.test.js
index a4e087607..43d9d65ac 100644
--- a/frontend/src/lib/muscles.test.js
+++ b/frontend/src/lib/muscles.test.js
@@ -266,7 +266,7 @@ describe('muscle balance windows and ranking', () => {
it('keeps catalogue precedence and deleted-custom snapshot weights', () => {
const known = { id: '0025', muscleGroups: ['quadriceps'], sets: [{ done: true }] }
const deleted = { id: 'deleted', muscleSnapshot: { muscleWeights: { chest: 1 } }, sets: [{ done: true }] }
- expect(loadOfWorkouts([{ entries: [known] }])).toEqual({ chest: 1, triceps: 0.4, deltoids: 0.4, biceps: 0.4 })
+ expect(loadOfWorkouts([{ entries: [known] }])).toEqual({ chest: 1, triceps: 0.4, deltoids: 0.4 })
expect(loadOfWorkouts([{ entries: [deleted] }])).toEqual({ chest: 1 })
})
})