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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
derive secondary additions via smOf overlay - raw dataset never mutated
root577c86b487c5
diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.jsindex 7f6adf4f5..f47cb88f4 100644--- a/frontend/src/lib/exercises.js+++ b/frontend/src/lib/exercises.js@@ -13,12 +13,17 @@ const SECONDARY_ADDITIONS = {'0861': ['rear deltoids'], // cable seated row}+// Secondary muscles for an exercise, with the small conservative additions applied as an+// overlay. The raw dataset is never mutated - consumers that want the pristine catalogue+// (export, print, import) keep reading EXDB untouched, while the muscle map sees the+// enriched list. Values follow the dataset's existing alias vocabulary.+export const smOf = ex => {+ const base = Array.isArray(ex?.sm) ? ex.sm : (ex?.sm ? [ex.sm] : [])+ return [...new Set([...base, ...(SECONDARY_ADDITIONS[ex?.id] || [])])]+}+export const EXIDX = {}-EXDB.forEach(e => {- const additions = SECONDARY_ADDITIONS[e.id]- if (additions) e.sm = [...new Set([...(e.sm || []), ...additions])]- EXIDX[e.id] = e-})+EXDB.forEach(e => { 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.js b/frontend/src/lib/muscles.jsindex c744812a0..12cf5f540 100644--- a/frontend/src/lib/muscles.js+++ b/frontend/src/lib/muscles.js@@ -7,7 +7,7 @@// map can actually draw, via ALIAS below. Anything genuinely undrawable (hands,// ankles, "cardiovascular system") maps to null and is dropped rather than guessed at.-import { EXIDX } from './exercises.js'+import { EXIDX , smOf } from './exercises.js'// The muscles a map can shade, in head-to-toe order — also the order of any list// built from them, so "what am I neglecting" reads top-down like a body.@@ -78,7 +78,7 @@ export function musclesOf(ex) {if (slug) out[slug] = Math.max(out[slug] || 0, w)}add(ex.tg, 1)- ;(ex.sm || []).forEach(m => add(m, SECONDARY))+ ;smOf(ex).forEach(m => add(m, SECONDARY))// Nothing recognised (custom exercises, or a target we don't draw) — use the body part.if (!Object.keys(out).length) Object.assign(out, BY_BODYPART[ex.bp] || {})return outdiff --git a/frontend/src/lib/muscles.test.js b/frontend/src/lib/muscles.test.jsindex 6d45dd507..3cde02e0e 100644--- a/frontend/src/lib/muscles.test.js+++ b/frontend/src/lib/muscles.test.js@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { EXIDX } from './exercises.js'+import { EXIDX, EXDB, smOf } from './exercises.js'import { musclesOf } from './muscles.js'// The catalogue keeps the source dataset's secondary-muscle spellings; musclesOf maps@@ -31,3 +31,14 @@ describe('catalogue secondary muscles', () => {}})})+++describe('catalogue secondary additions', () => {+ it('enriches the muscle map without mutating the raw dataset', () => {+ const raw = EXDB.find(e => e.id === '0027')+ expect(raw.sm).not.toContain('rear deltoids')+ expect(smOf(raw)).toContain('rear deltoids')+ // the alias collapses onto the deltoids slug in the canonical muscle map+ expect(musclesOf(raw)).toHaveProperty('deltoids')+ })+})