diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.js index 0bd6552..7f6adf4 100644 --- a/frontend/src/lib/exercises.js +++ b/frontend/src/lib/exercises.js @@ -2,8 +2,23 @@ import { EXDB } from './exercises-data.js' import { t } from './i18n-core.js' export { EXDB } + +// The generated dataset already supplies secondary muscles for most exercises. Keep the +// handful of conservative catalogue additions that are useful to the muscle map here so a +// dataset refresh does not erase them. Values follow the dataset's existing alias vocabulary. +const SECONDARY_ADDITIONS = { + '0027': ['rear deltoids'], // barbell bent over row + '0293': ['rear deltoids'], // dumbbell bent over row + '0499': ['rear deltoids'], // inverted row + '0861': ['rear deltoids'], // cable seated row +} + export const EXIDX = {} -EXDB.forEach(e => { EXIDX[e.id] = e }) +EXDB.forEach(e => { + const additions = SECONDARY_ADDITIONS[e.id] + if (additions) e.sm = [...new Set([...(e.sm || []), ...additions])] + EXIDX[e.id] = e +}) export const BODYPARTS = [...new Set(EXDB.map(e => e.bp))].sort() // Equipment options present in a given list of exercises, most common first (issue #6). diff --git a/frontend/src/lib/muscles.test.js b/frontend/src/lib/muscles.test.js new file mode 100644 index 0000000..6d45dd5 --- /dev/null +++ b/frontend/src/lib/muscles.test.js @@ -0,0 +1,33 @@ +import { describe, expect, it } from 'vitest' +import { EXIDX } from './exercises.js' +import { musclesOf } from './muscles.js' + +// The catalogue keeps the source dataset's secondary-muscle spellings; musclesOf maps +// those aliases to the canonical body-map slugs and applies the 0.4 support weight. +describe('catalogue secondary muscles', () => { + it('maps a bench press to chest, triceps and deltoids', () => { + expect(musclesOf(EXIDX['0025'])).toMatchObject({ + chest: 1, + triceps: 0.4, + deltoids: 0.4, + }) + }) + + it('maps a squat to glutes, quads and hamstrings', () => { + expect(musclesOf(EXIDX['0043'])).toMatchObject({ + gluteal: 1, + quadriceps: 0.4, + hamstring: 0.4, + }) + }) + + it('maps common row variations to the upper back, biceps and rear deltoids', () => { + for (const id of ['0027', '0293', '0499', '0861']) { + expect(musclesOf(EXIDX[id])).toMatchObject({ + 'upper-back': 1, + biceps: 0.4, + deltoids: 0.4, + }) + } + }) +})