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.

Import: the stored volume leaves warm-up sets out, like a workout finished in the app (QA C14)

Duarte Santose20201a87071
diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.js
index 104ad9b77..7317813ac 100644
--- a/frontend/src/lib/import-csv.js
+++ b/frontend/src/lib/import-csv.js
@@ -498,7 +498,9 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {
id: 'iw' + uid(), d, start, end: end > start ? end : start,
routineId: null, name: day.name || 'Imported', entries, prs: [],
}
- w.vol = entries.reduce((a, e) => a + e.sets.reduce((b, s) => b + (s.w || 0) * (s.r || 0), 0), 0)
+ // Work sets only, like `workoutVolume` for a workout finished in the app: warm-ups are
+ // promised to stay out of the volume, and this number is stored with the workout for good.
+ w.vol = entries.reduce((a, e) => a + e.sets.reduce((b, s) => b + (isWarmupRow(s) ? 0 : (s.w || 0) * (s.r || 0)), 0), 0)
return w
})
diff --git a/frontend/src/lib/import-csv.test.js b/frontend/src/lib/import-csv.test.js
index 6f392f62c..1a21a30ab 100644
--- a/frontend/src/lib/import-csv.test.js
+++ b/frontend/src/lib/import-csv.test.js
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest'
import { parseWorkoutCSV } from './import-csv.js'
+import { workoutVolume } from './history.js'
const CSV = [
'Date,Exercise,Weight,Reps,Set Type',
@@ -50,3 +51,23 @@ describe('gravl export', () => {
expect(cardio.entries[0].sets).toEqual([{ min: 0.4, speed: 0, done: true }])
})
})
+
+// A finished workout stores `vol = workoutVolume(w)`, which leaves warm-ups out; an imported one
+// wrote the sum of every set, so the History row, the heatmap and the month totals read a number
+// the app's own arithmetic never produces — and it stays wrong forever (QA C14).
+const HEVY_WARMUPS = [
+ 'title,start_time,end_time,description,exercise_title,superset_id,exercise_notes,set_index,set_type,weight_kg,reps,distance_km,duration_seconds,rpe',
+ '"QA","03 Mar 2025, 18:00","03 Mar 2025, 19:00","","Bench Press (Barbell)",,"",0,warmup,20,10,,,',
+ '"QA","03 Mar 2025, 18:00","03 Mar 2025, 19:00","","Bench Press (Barbell)",,"",1,normal,60,5,,,',
+ '"QA","03 Mar 2025, 18:00","03 Mar 2025, 19:00","","Bench Press (Barbell)",,"",2,normal,60,5,,,',
+ '"QA","03 Mar 2025, 18:00","03 Mar 2025, 19:00","","Squat (Barbell)",,"",0,warmup,40,5,,,',
+ '"QA","03 Mar 2025, 18:00","03 Mar 2025, 19:00","","Squat (Barbell)",,"",1,normal,100,5,,,',
+].join('\n')
+
+describe('imported volume', () => {
+ it('stores the work-set volume, the same number workoutVolume computes', () => {
+ const [w] = parseWorkoutCSV(HEVY_WARMUPS, { unit: 'kg' }).workouts
+ expect(w.vol).toBe(1100)
+ expect(w.vol).toBe(workoutVolume(w))
+ })
+})
diff --git a/frontend/src/lib/import-hevy.js b/frontend/src/lib/import-hevy.js
index b66c8718d..bed02b3c8 100644
--- a/frontend/src/lib/import-hevy.js
+++ b/frontend/src/lib/import-hevy.js
@@ -267,7 +267,8 @@ export function parseHevyWorkouts(workouts, templates, { unit = 'kg' } = {}) {
id: 'iw' + uid(), d, start: startMs, end: endMs > startMs ? endMs : startMs,
routineId: null, name: day.name || 'Imported', entries, prs: [],
}
- workout.vol = entries.reduce((a, e) => a + e.sets.reduce((b, s) => b + (s.w || 0) * (s.r || 0), 0), 0)
+ // Work sets only, the number `workoutVolume` gives a workout finished in the app; it is stored for good.
+ workout.vol = entries.reduce((a, e) => a + e.sets.reduce((b, s) => b + (isWarmupRow(s) ? 0 : (s.w || 0) * (s.r || 0)), 0), 0)
return workout
})
diff --git a/frontend/src/lib/import-hevy.test.js b/frontend/src/lib/import-hevy.test.js
index 7d7bc39cf..b395ea782 100644
--- a/frontend/src/lib/import-hevy.test.js
+++ b/frontend/src/lib/import-hevy.test.js
@@ -124,6 +124,9 @@ describe('parseHevyWorkouts', () => {
expect(pulldown.topW).toBe(52)
expect(parsed.warmups).toBe(1)
expect(parsed.rpeSets).toBe(1)
+ // The stored volume leaves the warm-up out, like a workout finished in the app (QA C14):
+ // 52×15 + 52×10 + 20×12 = 1,540, not 1,915.
+ expect(parsed.workouts[0].vol).toBe(1540)
const custom = entries.find(e => String(e.id).startsWith('im'))
expect(custom).toBeTruthy()