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.

warm-up sets: excluded from 1RM and progression only (volume semantics kept); tests

rootcbb3630423cc
diff --git a/frontend/src/lib/onerm.js b/frontend/src/lib/onerm.js
index daf9fae2e..c3a0b11cb 100644
--- a/frontend/src/lib/onerm.js
+++ b/frontend/src/lib/onerm.js
@@ -44,7 +44,7 @@ export function estimate1RM(w, r, formula = DEFAULT_FORMULA) {
export function bestSetOf(entry, formula = DEFAULT_FORMULA) {
let best = null
;(entry?.sets || []).forEach(s => {
- if (!s.done) return
+ if (!s.done || s.warmup) return
const est = estimate1RM(s.w, s.r, formula)
if (est !== null && (!best || est > best.est)) best = { est, w: Number(s.w), r: Math.round(Number(s.r)) }
})
diff --git a/frontend/src/lib/onerm.test.js b/frontend/src/lib/onerm.test.js
index 3460bb25e..57c6ec030 100644
--- a/frontend/src/lib/onerm.test.js
+++ b/frontend/src/lib/onerm.test.js
@@ -146,3 +146,19 @@ describe('is1RMRecord', () => {
expect(is1RMRecord(S, 'bench', { id: 'bench', sets: [{ w: 200, r: 5, done: false }] })).toBeNull()
})
})
+
+
+describe('warm-up sets and 1RM', () => {
+ const ENTRY = { id: 'warm-test', sets: [
+ { w: 20, r: 8, done: true, warmup: true },
+ { w: 80, r: 5, done: true },
+ ] }
+
+ it('does not let a ticked-off warm-up set set or raise the estimated 1RM', () => {
+ const working = { id: 'warm-test', sets: [{ w: 80, r: 5, done: true }] }
+ expect(bestSetOf(ENTRY)).toEqual(bestSetOf(working))
+ expect(best1RM({ workouts: [{ entries: [ENTRY] }] }, 'warm-test')).toBe(
+ best1RM({ workouts: [{ entries: [working] }] }, 'warm-test'),
+ )
+ })
+})
diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.js
index 17825a8f4..6b01dc329 100644
--- a/frontend/src/lib/progression.js
+++ b/frontend/src/lib/progression.js
@@ -110,7 +110,7 @@ export function readSession(entry, fallback) {
const held = sets.map(s => (s.done ? (s.sec || 0) : 0))
return {
mode, goal, held,
- weight: Math.max(0, ...sets.filter(s => s.done).map(s => s.w || 0)),
+ weight: Math.max(0, ...sets.filter(s => s.done && !s.warmup).map(s => s.w || 0)),
best: Math.max(0, ...held),
ok: goal > 0 && enough && held.length > 0 && held.every(h => h >= goal)
}
@@ -119,7 +119,7 @@ export function readSession(entry, fallback) {
const reps = sets.map(s => (s.done ? (s.r || 0) : 0))
return {
mode, goal, reps,
- weight: Math.max(0, ...sets.filter(s => s.done).map(s => s.w || 0)),
+ weight: Math.max(0, ...sets.filter(s => s.done && !s.warmup).map(s => s.w || 0)),
count: reps.length, // the dimension bodyweight work grows (#33)
low: reps.length ? Math.min(...reps) : 0,
amrap: reps.length ? reps[reps.length - 1] : 0, // Greyskull's final set
@@ -132,7 +132,7 @@ export function sessionsFor(S, exId, fallback) {
const out = []
;(S.workouts || []).forEach(w => {
const entry = w.entries.find(e => e.id === exId)
- if (entry && entry.sets.some(s => s.done)) out.push({ d: w.d, ...readSession(entry, fallback) })
+ if (entry && entry.sets.some(s => s.done && !s.warmup)) out.push({ d: w.d, ...readSession(entry, fallback) })
})
return out
}
@@ -250,7 +250,7 @@ export function nextPrescription(S, cfg, routine) {
export function applyPrescription(sets, p) {
if (!p || p.kind === 'off' || p.kind === 'first') return sets
const out = sets.map(s => {
- if (s.done) return s
+ if (s.done && !s.warmup) return s
const o = { ...s }
if (p.weight != null) o.w = p.weight
if (p.reps != null) o.r = p.reps