Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
fix(stats): exclude warm-up sets from 1RM and export set_type and rir
NullX3c61249522cd
diff --git a/lib/models/workout.dart b/lib/models/workout.dartindex ee2dc78..fd86c95 100644--- a/lib/models/workout.dart+++ b/lib/models/workout.dart@@ -31,10 +31,11 @@ class LoggedSet {bool get counts => kind != SetKind.warmup;bool get sided => left != null && right != null;- double get volume => reps * weight;+ double? get rir => rpe == null ? null : 10 - rpe!;+ double get volume => counts ? reps * weight : 0;double get oneRm {- if (reps <= 0) return 0;+ if (!counts || reps <= 0) return 0;final pct = rpePercent(reps, rpe);return pct == null ? weight * (1 + reps / 30) : weight / pct;}diff --git a/lib/services/local_store.dart b/lib/services/local_store.dartindex aa6b9d3..721c5f8 100644--- a/lib/services/local_store.dart+++ b/lib/services/local_store.dart@@ -81,7 +81,7 @@ class Store {String exportCsv(List<LoggedSession> sessions) {final rows = StringBuffer(- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note\n');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,set_type,rpe,rir,note\n');final ordered = [...sessions]..sort((a, b) => a.date.compareTo(b.date));for (final s in ordered) {final day = s.date.toIso8601String().split('T').first;@@ -99,7 +99,9 @@ class Store {_num(st.oneRm),st.km == null ? '' : _num(st.km!),st.sec ?? '',+ st.kind.name,st.rpe == null ? '' : _num(st.rpe!),+ st.rir == null ? '' : _num(st.rir!),_csv(st.note),].join(','));}diff --git a/lib/services/workout_import.dart b/lib/services/workout_import.dartindex 065c056..6ba50a3 100644--- a/lib/services/workout_import.dart+++ b/lib/services/workout_import.dart@@ -167,6 +167,7 @@ const _formats = <ImportFormat, _Fmt>{reps: ['reps'],weightKg: ['weight_kg'],weightLb: [],+ setType: ['set_type'],muscle: ['muscle'],),ImportFormat.generic: _Fmt(diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dartindex 5b78c36..9b2e426 100644--- a/lib/state/stats_state.dart+++ b/lib/state/stats_state.dart@@ -277,6 +277,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt}double _setScore(String id, LoggedSet s) {+ if (!s.counts) return 0;if ((s.km ?? 0) > 0) return s.km!;if (s.weight > 0 || isAssisted(id)) return liftScore(id, s);if (s.reps > 0) return s.reps.toDouble();@@ -292,7 +293,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt}bool _beats(String id, LoggedSet st, _Best? best) {- if (best == null || st.reps <= 0 && (st.sec ?? 0) <= 0 && (st.km ?? 0) <= 0) return false;+ if (best == null || !st.counts || st.reps <= 0 && (st.sec ?? 0) <= 0 && (st.km ?? 0) <= 0) return false;if (_setScore(id, st) > best.score + 1e-9) return true;if (isAssisted(id) || st.weight <= 0) return false;if (st.weight > best.weight + 1e-9 || st.weight * st.reps > best.volume + 1e-9) return true;@@ -800,6 +801,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineStdouble get _assistBodyKg => profile.weightKg > 0 ? profile.weightKg : 75;double liftScore(String id, LoggedSet s) {+ if (!s.counts) return 0;if (!isAssisted(id)) return s.oneRm;if (s.reps <= 0) return 0;return math.max(0.0, _assistBodyKg - s.weight) * (1 + s.reps / 30);@@ -1664,7 +1666,10 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt_round1(r.ex.workingSets.where((s) => s.reps > 0).map((s) => s.weight).reduce(math.min)),];}- return h.map((r) => _round1(r.ex.bestOneRm)).toList();+ return [+ for (final r in h)+ if (r.ex.bestOneRm > 0) _round1(r.ex.bestOneRm),+ ];}bool canShowRelative(String id) =>@@ -1753,7 +1758,8 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineStList<double> bestRepsSeries(String id) => [for (final r in exerciseHistory(id).reversed)- r.ex.sets.where((s) => s.counts).fold(0, (m, s) => math.max(m, s.reps)).toDouble(),+ if (r.ex.workingSets.isNotEmpty)+ r.ex.workingSets.fold(0, (m, s) => math.max(m, s.reps)).toDouble(),];static const _habitWindowDays = 120;diff --git a/test/export_test.dart b/test/export_test.dartindex 58753d6..055860d 100644--- a/test/export_test.dart+++ b/test/export_test.dart@@ -17,7 +17,7 @@ void main() {]);final lines = csv.trim().split('\n');expect(lines.first,- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,set_type,rpe,rir,note');expect(lines.length, 3);expect(lines[1], startsWith('2026-07-14,Barbell Bench Press,chest,1,10,60,600,'));expect(lines[2], contains(',2,8,70,560,'));@@ -30,7 +30,7 @@ void main() {final row = csv.trim().split('\n')[1];expect(row, contains('"Chest Dip, Assisted"'));- expect(row.replaceAll(RegExp('"[^"]*"'), 'X').split(',').length, 12);+ expect(row.replaceAll(RegExp('"[^"]*"'), 'X').split(',').length, 14);});test('a name with quotes is escaped, not mangled', () {@@ -69,7 +69,7 @@ void main() {test('no sessions still yields a valid header-only file', () {expect(store.exportCsv([]).trim(),- 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe,note');+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,set_type,rpe,rir,note');});test('a set note goes in the last column, escaped', () {@@ -80,4 +80,16 @@ void main() {expect(lines[1], endsWith(',"knee, a bit sore"'));expect(lines[2], endsWith(','));});++ test('warm-up 40 kg x 8 does not export est_1rm_kg and csv serializes set_type and rir', () {+ final csv = store.exportCsv([+ _session(DateTime(2026, 11, 10), 'Barbell Bench Press', [+ LoggedSet(8, 40, kind: SetKind.warmup, rpe: 7),+ LoggedSet(5, 80, rpe: 8.5),+ ]),+ ]);+ final lines = csv.trim().split('\n');+ expect(lines[1], '2026-11-10,Barbell Bench Press,chest,1,8,40,0,0,,,warmup,7,3,');+ expect(lines[2], '2026-11-10,Barbell Bench Press,chest,2,5,80,400,97.09,,,normal,8.5,1.5,');+ });}diff --git a/test/rpe_test.dart b/test/rpe_test.dartindex ccf3dd4..554fea8 100644--- a/test/rpe_test.dart+++ b/test/rpe_test.dart@@ -73,9 +73,9 @@ void main() {]),]);final rows = csv.trim().split('\n');- expect(rows.first, endsWith(',rpe,note'));- expect(rows[1], endsWith(',8.5,'));- expect(rows[2], endsWith(',,'));+ expect(rows.first, endsWith(',set_type,rpe,rir,note'));+ expect(rows[1], endsWith(',normal,8.5,1.5,'));+ expect(rows[2], endsWith(',normal,,,'));final back = parseImport(csv);final sets = back.sessions.single.exercises.single.sets;diff --git a/test/stats_totals_test.dart b/test/stats_totals_test.dartindex 050208d..7d789b5 100644--- a/test/stats_totals_test.dart+++ b/test/stats_totals_test.dart@@ -77,6 +77,24 @@ void main() {expect(fit.totalSets, 0);expect(fit.muscleSetsOver(7), isEmpty);});++ test('warm-up 40 kg x 8 does not overwrite est_1rm_kg or working tonnage', () {+ final warmup = LoggedSet(8, 40, kind: SetKind.warmup);+ final work = LoggedSet(5, 30);+ expect(warmup.oneRm, 0);+ expect(warmup.volume, 0);+ expect(fit.liftScore('EIeI8Vf', warmup), 0);++ fit.sessions+ ..add(session(2, [warmup]))+ ..add(session(1, [warmup, work]));++ final pr = fit.personalRecords.single;+ expect(pr.oneRm, closeTo(35.0, 0.1));+ expect(fit.oneRmSeries('EIeI8Vf'), [35.0]);+ expect(fit.bestRepsSeries('EIeI8Vf'), [5]);+ expect(fit.totalVolumeKg, 150);+ });});group('inches users are not fed centimetres', () {