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.

feat(1rm): pick the 1RM formula in Settings → Units

Duarte Santos6dcda790cf05
diff --git a/frontend/src/lib/onerm.js b/frontend/src/lib/onerm.js
index 5a590e155..45e1e5008 100644
--- a/frontend/src/lib/onerm.js
+++ b/frontend/src/lib/onerm.js
@@ -35,6 +35,18 @@ export const FORMULAS = {
}
export const DEFAULT_FORMULA = 'epley'
+// The formula a profile picked in Settings (Discord "toggle which 1RM formula to use"). Anything
+// this build does not know reads as the default, so an older or newer device can't break it.
+// Names as the formulas' authors are known, so not translated. 'weighted' blends all seven.
+export const FORMULA_NAMES = {
+ epley: 'Epley', brzycki: 'Brzycki', lombardi: 'Lombardi', oconner: 'O’Conner',
+ mayhew: 'Mayhew', wathan: 'Wathan', lander: 'Lander',
+}
+export const formulaOf = S => {
+ const f = S?.oneRmFormula
+ return f === 'weighted' || Object.hasOwn(FORMULAS, f) ? f : DEFAULT_FORMULA
+}
+
// ── RIR %1RM map (Mike Tuchscherer / RTS scale) ─────────────────────────────────
// Index 0 = 1 rep to failure, index 14 = 15 reps to failure.
const RIR_PCT = [
@@ -134,7 +146,7 @@ export function bestSetOf(entry, formula = DEFAULT_FORMULA) {
? [s.sides.L, s.sides.R].filter(side => side?.done === true)
: [s]
sets.forEach(set => {
- const est = estimate1RM(set.w, set.r, formula)
+ const est = estimate1RM(set.w, set.r, formula, set.rir ?? null)
if (est !== null && (!best || est > best.est)) best = { est, w: Number(set.w), r: Math.round(Number(set.r)) }
})
})
@@ -152,7 +164,7 @@ function bestSetOfEntries(entries, formula = DEFAULT_FORMULA) {
// One point per workout in which the exercise produced an estimate — feeds the trend chart.
// Chronological, matching the order workouts are appended in.
-export function e1rmSeries(S, exId, formula = DEFAULT_FORMULA) {
+export function e1rmSeries(S, exId, formula = formulaOf(S)) {
if (isAssisted(exId)) return []
const pts = []
;(S.workouts || []).forEach(w => {
@@ -164,7 +176,7 @@ export function e1rmSeries(S, exId, formula = DEFAULT_FORMULA) {
// All-time best estimate for an exercise, with the set and date it came from — the source
// matters, because "142.5 kg est. from 100×10" is a very different claim from "from 140×1".
-export function best1RM(S, exId, formula = DEFAULT_FORMULA) {
+export function best1RM(S, exId, formula = formulaOf(S)) {
let best = null
e1rmSeries(S, exId, formula).forEach(p => { if (!best || p.y > best.est) best = { est: p.y, w: p.w, r: p.r, d: p.d, t: p.t } })
return best
@@ -172,7 +184,7 @@ export function best1RM(S, exId, formula = DEFAULT_FORMULA) {
// Did this workout beat every estimate that came before it? Used for the finish summary,
// so it compares against history that does not yet contain `w`.
-export function is1RMRecord(S, exId, entry, formula = DEFAULT_FORMULA) {
+export function is1RMRecord(S, exId, entry, formula = formulaOf(S)) {
const now = bestSetOf(entry, formula)
if (!now) return null
const prev = best1RM(S, exId, formula)
diff --git a/frontend/src/lib/onerm.test.js b/frontend/src/lib/onerm.test.js
index e1329bec8..3f8f94b7b 100644
--- a/frontend/src/lib/onerm.test.js
+++ b/frontend/src/lib/onerm.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
-import { estimate1RM, bestSetOf, e1rmSeries, best1RM, is1RMRecord, REP_CAP, WEIGHTED_REP_CAP, FORMULAS, calculate1RMAccuracy } from './onerm.js'
+import { estimate1RM, bestSetOf, e1rmSeries, best1RM, is1RMRecord, REP_CAP, WEIGHTED_REP_CAP, FORMULAS, calculate1RMAccuracy, formulaOf } from './onerm.js'
describe('estimate1RM', () => {
it('returns the load unchanged for a single rep', () => {
@@ -350,3 +350,18 @@ describe('warm-up sets and 1RM', () => {
)
})
})
+
+describe('the formula a profile picked (Settings, Discord request)', () => {
+ const S = { workouts: [{ d: '2026-10-01', entries: [{ id: 'x', sets: [{ w: 100, r: 8, done: true }] }] }] }
+ it('reads the default when nothing or something unknown is stored', () => {
+ expect(formulaOf({})).toBe('epley')
+ expect(formulaOf({ oneRmFormula: 'toString' })).toBe('epley')
+ expect(formulaOf({ oneRmFormula: 'brzycki' })).toBe('brzycki')
+ expect(formulaOf({ oneRmFormula: 'weighted' })).toBe('weighted')
+ })
+ it('the stored formula drives best1RM without every caller passing it', () => {
+ expect(best1RM(S, 'x').est).toBe(estimate1RM(100, 8, 'epley'))
+ expect(best1RM({ ...S, oneRmFormula: 'brzycki' }, 'x').est).toBe(estimate1RM(100, 8, 'brzycki'))
+ expect(best1RM({ ...S, oneRmFormula: 'brzycki' }, 'x').est).toBeLessThan(best1RM(S, 'x').est)
+ })
+})
diff --git a/frontend/src/lib/per-set.js b/frontend/src/lib/per-set.js
index 058b1e3ce..9d8f8a94a 100644
--- a/frontend/src/lib/per-set.js
+++ b/frontend/src/lib/per-set.js
@@ -21,7 +21,7 @@ const weightOf = set => (isSideSet(set) ? Math.max(0, ...doneSides(set).map(side
* and the rep that went missing in the last set is the thing to see. A set past the estimate's
* rep cap has no point, as on the Est. 1RM curve. A per-side set is estimated from one side's
* reps, not both added up. */
-export function perSetSessions(workouts, exId, { metric = 'weight' } = {}) {
+export function perSetSessions(workouts, exId, { metric = 'weight', formula } = {}) {
const out = []
for (const w of workouts || []) {
let n = 0
@@ -34,7 +34,7 @@ export function perSetSessions(workouts, exId, { metric = 'weight' } = {}) {
if (!hasCompletedWork(set)) continue
const wt = weightOf(set), r = completedRepsOf(set)
const perSide = isSideSet(set) ? r / doneSides(set).length : r
- const y = metric === 'reps' ? r : metric === 'e1rm' ? estimate1RM(wt, perSide) || 0 : wt
+ const y = metric === 'reps' ? r : metric === 'e1rm' ? estimate1RM(wt, perSide, formula, set.rir ?? null) || 0 : wt
if (y > 0) sets.push({ n, y, w: wt, r })
}
}
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index b28bbe24d..123612f1b 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -31,7 +31,7 @@ import { exerciseMuscleSnapshot, loadOfWorkouts, MUSCLES, MUSCLE_NAME, muscleWei
import { parseImport, mergeImport } from './lib/import-csv.js'
import { importHevyData, HevyApiError, HEVY_DEV_SETTINGS, mergeHevyRoutines } from './lib/import-hevy.js'
import { buildPlanBundle, parsePlan, mergePlan, printPlan, planPrintHTML } from './lib/plan-share.js'
-import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'
+import { estimate1RM, best1RM, is1RMRecord, REP_CAP, formulaOf, FORMULA_NAMES } from './lib/onerm.js'
import { exerciseHistory } from './lib/exercise-history.js'
import { policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS, weightIncrement } from './lib/progression.js'
import { normalizeRepRange } from './lib/rep-range.js'
@@ -838,7 +838,7 @@ function OneRM({ ex }) {
const best = best1RM(st, ex.id)
const [w, setW] = useState(best ? best.w : (st.exWeights[ex.id] || {}).w || 20)
const [r, setR] = useState(best ? best.r : 5)
- const est = estimate1RM(w, r)
+ const est = estimate1RM(w, r, formulaOf(st))
return <>
<h4 className="sec">{t('Estimated 1RM')}</h4>
{best && <div className="small" style={{ marginBottom: 8 }}>
@@ -855,7 +855,9 @@ function OneRM({ ex }) {
</div>
<div className="small dim">{est === null
? t('Enter a weight and 1–{0} reps. Beyond that it’s basically guesswork.', REP_CAP)
- : t('Epley formula: calculated from one set, not a tested max.')}</div>
+ : formulaOf(st) === 'weighted'
+ ? t('A blend of seven formulas: calculated from one set, not a tested max.')
+ : t('{0} formula: calculated from one set, not a tested max.', FORMULA_NAMES[formulaOf(st)])}</div>
</>
}
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 9fb822fdf..b17fb9db3 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -3,6 +3,7 @@ import { useNavigate, useParams, useLocation, Navigate } from 'react-router-dom'
import { useStore, DEF, hasData } from '../store/useStore.js'
import { workoutControls } from '../lib/workout-controls.js'
import { speedUnitOf } from '../lib/speed.js'
+import { formulaOf, FORMULA_NAMES } from '../lib/onerm.js'
import { copyText } from '../lib/clipboard.js'
import { useUI } from '../store/useUI.js'
import { ACCENTS, ACCENT_NAMES, todayISO, localTZ, weekStartOf, MONDAY, SUNDAY, fmtPlate } from '../lib/format.js'
@@ -680,6 +681,20 @@ export default function Settings({ page = null, find = null, via = null }) {
options={[{ value: 'kmh', label: 'km/h' }, { value: 'mph', label: 'mph' }]}
value={speedUnitOf(S)} onChange={v => update(s => { s.speedUnit = v })} />
</Row>
+ {/* Which formula turns a set into an estimated 1RM (Discord, #155): the exercise page,
+ the 1RM chart and records all follow it. Formula names are people, not words. */}
+ <SelectRow icon="chart" iconTint="var(--teal)" title={t('1RM formula')}
+ value={formulaOf(S)} onChange={v => update(s => { s.oneRmFormula = v })}
+ options={[
+ { value: 'epley', label: 'Epley', subtitle: t('The common one. A bit generous at higher reps.') },
+ { value: 'brzycki', label: 'Brzycki', subtitle: t('More conservative above five reps.') },
+ { value: 'lombardi', label: 'Lombardi', subtitle: t('Generous, especially at high reps.') },
+ { value: 'oconner', label: FORMULA_NAMES.oconner, subtitle: t('The most conservative of the classics.') },
+ { value: 'mayhew', label: 'Mayhew' },
+ { value: 'wathan', label: 'Wathan' },
+ { value: 'lander', label: 'Lander' },
+ { value: 'weighted', label: t('Blend of all'), subtitle: t('Averages seven formulas and reads your RIR when you log it.') },
+ ]} />
</Section>
</>,
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index 548db9613..b0b0381af 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -15,7 +15,7 @@ import { loadOfWeeklyPlan, loadOfWorkouts, muscleBalanceWindow, rankOf, MUSCLES,
import { fatigueOf, strengthOf, STRENGTH_FLOOR, LB_TO_KG } from '../lib/recovery.js'
import { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'
import { fatigueStateOf } from '../lib/recovery-view.js'
-import { e1rmSeries, best1RM } from '../lib/onerm.js'
+import { e1rmSeries, best1RM, formulaOf } from '../lib/onerm.js'
import { maxRepsSeries } from '../lib/pyramid.js'
import { perSetSessions, perSetLines, dropOffSet } from '../lib/per-set.js'
import {
@@ -548,11 +548,12 @@ export default function Stats() {
// Loaded work is drawn as each set's estimated 1RM, so straight sets at one weight still part
// where reps were lost. Reps instead for unloaded work, an assistance machine (where a 1RM
// reads backwards), or a history of sets all past the estimate's rep cap.
+ const oneRmFormula = formulaOf(S)
const perSet = useMemo(() => {
if (!curEx || curMode !== 'reps') return null
const usable = list => list.length >= 2 && list.some(s => s.sets.length >= 2)
let metric = repsOnly || isAssisted(curEx) ? 'reps' : 'e1rm'
- let sessions = perSetSessions(workouts, curEx, { metric })
+ let sessions = perSetSessions(workouts, curEx, { metric, formula: oneRmFormula })
if (metric === 'e1rm' && !usable(sessions)) sessions = perSetSessions(workouts, curEx, { metric: metric = 'reps' })
if (!usable(sessions)) return null
const { lines, hidden } = perSetLines(sessions)
@@ -568,7 +569,7 @@ export default function Stats() {
metric,
drop: dropOffSet(sessions),
}
- }, [workouts, curEx, curMode, repsOnly])
+ }, [workouts, curEx, curMode, repsOnly, oneRmFormula])
const onSets = !!perSet && exMetric === 'sets'
const onE1 = showE1 && exMetric === 'e1rm'
const onEff = showEff && exMetric === 'effort'
diff --git a/frontend/src/views/settings-pages.js b/frontend/src/views/settings-pages.js
index 7ad19fae7..838144cc5 100644
--- a/frontend/src/views/settings-pages.js
+++ b/frontend/src/views/settings-pages.js
@@ -93,6 +93,7 @@ export const SEARCH = [
{ page: 'units', title: 'Weight unit', icon: 'scale', tint: 'var(--teal)', kw: 'kg lb lbs pounds kilos kilograms unit' },
{ page: 'units', title: 'Weight decimals', icon: 'ruler', tint: 'var(--teal)', kw: 'decimals precision microplates rounding' },
{ page: 'units', title: 'Speed unit', icon: 'figureRun', tint: 'var(--teal)', kw: 'speed mph kmh km/h miles cardio' },
+ { page: 'units', title: '1RM formula', icon: 'chart', tint: 'var(--teal)', kw: '1rm one rep max epley brzycki lombardi formula estimate' },
// Equipment
{ page: 'equipment', title: 'Plates', icon: 'plate', tint: 'var(--orange)', kw: 'plates bar plate math barbell' },
{ page: 'equipment', title: 'Filter by equipment', icon: 'kettlebell', tint: 'var(--green)', kw: 'equipment filter home gym', when: c => c.profiles },