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
Import: body part from an exercise name — the specific word before the broad one (a grip is a modifier, a wrist curl is a forearm exercise, a leg curl and a Romanian deadlift are legs, chest-supported is a row)
Duarte Santos0f7e3e1291cc
diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.jsindex a53991f8e..f15e6df8d 100644--- a/frontend/src/lib/import-csv.js+++ b/frontend/src/lib/import-csv.js@@ -265,19 +265,28 @@ export function matchHevyTitle(name) {// Hevy exports no category column, so every invented exercise fell through to the// 'upper legs' default and a third of an imported history was attributed to the legs in// the muscle map. When there is no category, read the body part off the name instead.+// Order is the rule: the first match wins, so the specific word has to come before the broad one.+// A grip is a modifier on a row or a pulldown, never the movement ("Chest Supported T Row Neutral+// Grip" is a back exercise); a wrist or reverse curl is a forearm exercise that happens to say+// "curl"; a leg curl is not an arm curl; and a Romanian or stiff-leg deadlift trains the legs where+// the conventional pull is filed under the back. "grip" alone still reads as forearms — last.const NAME_BP = [- [/\b(curl|bicep|biceps|tricep|triceps|skullcrusher|pushdown)\b/, 'upper arms'],- [/\b(wrist|forearm|forearms|grip)\b/, 'lower arms'],+ [/\b(wrist|forearm|forearms|reverse curl)\b/, 'lower arms'],+ [/\b(leg curl|leg curls|hamstring curl|nordic)\b/, 'upper legs'],+ [/\b(romanian|rdl|stiff leg|stiff legged|straight leg)\b.*\bdeadlifts?\b|\brdl\b/, 'upper legs'],+ [/\b(curl|curls|bicep|biceps|tricep|triceps|skullcrusher|pushdown)\b/, 'upper arms'],+ [/\bchest supported\b/, 'back'], // where the chest rests, not what it trains[/\b(bench|chest|pec|fly|flye|crossover|crossovers|dip)\b/, 'chest'],- [/\b(row|pulldown|pullup|pull up|chin up|lat|lats|back|deadlift|shrug)\b/, 'back'],+ [/\b(row|rows|pulldown|pullup|pull up|chin up|lat|lats|back|deadlift|deadlifts|shrug)\b/, 'back'],[/\b(shoulder|delt|delts|overhead|lateral raise|front raise|face pull|press up)\b/, 'shoulders'],[/\b(calf|calves)\b/, 'lower legs'],- [/\b(squat|lunge|leg|glute|hamstring|quad|hip thrust|deadlift)\b/, 'upper legs'],+ [/\b(squat|lunge|leg|glute|hamstring|quad|hip thrust)\b/, 'upper legs'],[/\b(ab|abs|core|plank|crunch|sit up|oblique|russian twist)\b/, 'waist'],[/\b(run|running|jog|bike|cycling|rope|ropes|jump|jacks|burpee|sprint|treadmill|stair)\b/, 'cardio'],[/\bneck\b/, 'neck'],+ [/\bgrip\b/, 'lower arms'],]-const bpFromName = name => (NAME_BP.find(([re]) => re.test(name)) || [])[1] || null+export const bpFromName = name => (NAME_BP.find(([re]) => re.test(name)) || [])[1] || null// Categories the exporters use -> the dataset's body parts, for exercises we invent.const CATEGORY_BP = {diff --git a/frontend/src/lib/import-name-bodypart.test.js b/frontend/src/lib/import-name-bodypart.test.jsnew file mode 100644index 000000000..976731b8c--- /dev/null+++ b/frontend/src/lib/import-name-bodypart.test.js@@ -0,0 +1,36 @@+// The fallback that reads a body part off an exercise name when the export has no category+// column (Hevy). First match wins, so the order of the rules is the behaviour — reported on+// Discord by rubik_97 with the three cases below.+import { describe, expect, it } from 'vitest'+import { bpFromName } from './import-csv.js'++const bp = name => bpFromName(name.toLowerCase())++describe('body part from an exercise name', () => {+ it('reads a grip as a modifier, not as the movement', () => {+ expect(bp('Chest Supported T Row Neutral Grip')).toBe('back')+ expect(bp('Wide Grip Lat Pulldown')).toBe('back')+ expect(bp('Close Grip Bench Press')).toBe('chest')+ })++ it('files wrist and reverse curls under the forearms, not the upper arms', () => {+ expect(bp('Wrist Curl')).toBe('lower arms')+ expect(bp('Barbell Reverse Curl')).toBe('lower arms')+ expect(bp('Hammer Curl')).toBe('upper arms')+ })++ it('keeps leg curls and the hamstring deadlifts on the legs', () => {+ expect(bp('Lying Leg Curl')).toBe('upper legs')+ expect(bp('Romanian Deadlift')).toBe('upper legs')+ expect(bp('Stiff Leg Deadlift')).toBe('upper legs')+ expect(bp('RDL')).toBe('upper legs')+ expect(bp('Deadlift')).toBe('back')+ })++ it('still reads a bare grip exercise as forearms, and the rest as before', () => {+ expect(bp('Grip Trainer')).toBe('lower arms')+ expect(bp('Back Squat')).toBe('back') // unchanged: "back" is matched before "squat"+ expect(bp('Standing Calf Raise')).toBe('lower legs')+ expect(bp('Something Unheard Of')).toBe(null)+ })+})