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
Plates: 2, 1.5 and 1 kg change plates, and 1 and 0.5 lb (#510, Discord)
Duarte Santos6f7c84329942
diff --git a/frontend/src/lib/plates.js b/frontend/src/lib/plates.jsindex 86e6b4b2a..fefb49c45 100644--- a/frontend/src/lib/plates.js+++ b/frontend/src/lib/plates.js@@ -15,13 +15,16 @@ import { isBw } from './history.js'import { weightIncrement } from './progression.js'import { ownedWeightsFor, ownedFloor } from './dumbbells.js'-/** The plate sizes the inventory editor lists, heaviest first, per unit. */+/** The plate sizes the inventory editor lists, heaviest first, per unit. The kg list has the+ * 2, 1.5 and 1 kg change plates of gyms that stock whole and half kilos (#510, Discord "1 kg /+ * 2 kg discs"), and the lb list the 1 lb and 0.5 lb fractional plates. */export const PLATE_SIZES = {- kg: [25, 20, 15, 10, 5, 2.5, 1.25, 0.5],- lb: [45, 35, 25, 15, 10, 5, 2.5, 1.25],+ kg: [25, 20, 15, 10, 5, 2.5, 2, 1.5, 1.25, 1, 0.5],+ lb: [45, 35, 25, 15, 10, 5, 2.5, 1.25, 1, 0.5],}-/** Sizes a gym without an inventory of its own is assumed NOT to have. */-const UNCOMMON = { kg: new Set([0.5]), lb: new Set([15, 1.25]) }+/** Sizes a gym without an inventory of its own is assumed NOT to have: the standard set, the+ * one every profile had before, stays exactly what it was. */+const UNCOMMON = { kg: new Set([2, 1.5, 1, 0.5]), lb: new Set([15, 1.25, 1, 0.5]) }/** Pairs of each size the default inventory holds — plenty, the way a rack is. */export const DEFAULT_PAIRS = 6diff --git a/frontend/src/lib/plates.test.js b/frontend/src/lib/plates.test.jsindex 89bbc3477..785a39dfd 100644--- a/frontend/src/lib/plates.test.js+++ b/frontend/src/lib/plates.test.js@@ -267,3 +267,23 @@ describe('loads between quarter-unit boundaries', () => {expect(snap(48.74)).toBe(40)})})++// #510 and Discord "1 kg / 2 kg discs": whole and half kilo change plates, and 1 / 0.5 lb.+describe('change plates beyond the standard set', () => {+ test('the editor lists them, heaviest first, and the standard set is what it always was', () => {+ expect(PLATE_SIZES.kg).toEqual([25, 20, 15, 10, 5, 2.5, 2, 1.5, 1.25, 1, 0.5])+ expect(PLATE_SIZES.lb).toEqual([45, 35, 25, 15, 10, 5, 2.5, 1.25, 1, 0.5])+ for (const u of ['kg', 'lb']) expect([...PLATE_SIZES[u]].sort((a, b) => b - a)).toEqual(PLATE_SIZES[u])+ expect(inventoryFor({ unit: 'kg' }).map(p => p.w)).toEqual([25, 20, 15, 10, 5, 2.5, 1.25])+ expect(inventoryFor({ unit: 'lb' }).map(p => p.w)).toEqual([45, 35, 25, 10, 5, 2.5])+ for (const w of [2, 1.5, 1]) expect(pairsOf({ unit: 'kg' }, w)).toBe(0)+ })+ test('counted ones load like any other size', () => {+ const inv = inventoryFor({ unit: 'kg', plates: { kg: { 20: 2, 10: 1, 5: 1, 2.5: 1, 2: 1, 1.5: 1, 1: 1 } } })+ expect(plateStack(4.5, inv)).toEqual({ plates: [2.5, 2], missing: 0 })+ expect(plateStack(3, inv)).toEqual({ plates: [2, 1], missing: 0 })+ expect(plateStack(1.5, inv)).toEqual({ plates: [1.5], missing: 0 })+ const S = { unit: 'kg', plates: withPlatePairs({ unit: 'kg' }, 2, 1, 1000) }+ expect(inventoryFor(S).map(p => p.w)).toEqual([25, 20, 15, 10, 5, 2.5, 2, 1.25])+ })+})