Repository navigation
workout: rucking, with the pack weight kept on each ruck #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,7 +741,7 @@ class LocalDb { | |
| /// pass it: sqflite throws `ArgumentError('onCreate must be null if no | ||
| /// version is specified')` BEFORE opening anything when `onCreate` is given | ||
| /// without `version` (sqflite_common database_mixin.dart). | ||
| static const int schemaVersion = 62; | ||
| static const int schemaVersion = 63; | ||
|
|
||
| /// In-memory cache identity, advanced after open, wipe or committed import. | ||
| /// It is local to this isolate; no cache survives a process restart. | ||
|
|
@@ -1615,6 +1615,11 @@ class LocalDb { | |
| await _createStoreIdentity(db); | ||
| await _createDayCheckpoint(db); | ||
| } | ||
| if (oldV < 63) { | ||
| // Two nullable columns, no backfill: no earlier session knew its | ||
| // pack weight. | ||
| await _ensureSessionLoadColumns(db); | ||
| } | ||
| }, | ||
| onOpen: (db) async { | ||
| await _repairOpenSchema(db); | ||
|
|
@@ -6328,6 +6333,18 @@ class LocalDb { | |
| await _addColumnIfMissing(db, 'sessions', 'trace_samples', 'INTEGER'); | ||
| } | ||
|
|
||
| /// The weight carried on a ruck (v63), and the body weight it was carried | ||
| /// at, both in kg and both typed by the user: `load_kg` on the setup screen, | ||
| /// `body_kg` copied from the profile when the session ends. NULL is "not | ||
| /// entered" on every other session and every import. `body_kg` is banked | ||
| /// with the load rather than read from the profile later because a share of | ||
| /// body weight worked out against next year's weight describes a different | ||
| /// outing. | ||
| static Future<void> _ensureSessionLoadColumns(Database db) async { | ||
| await _addColumnIfMissing(db, 'sessions', 'load_kg', 'REAL'); | ||
| await _addColumnIfMissing(db, 'sessions', 'body_kg', 'REAL'); | ||
|
Comment on lines
+6344
to
+6345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Cloud imports erase carried weights When a cloud re-import writes an existing session ID after the user has entered or corrected its weights, Merge the existing weights into the imported row before calling
Comment on lines
+6344
to
+6345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Workout CSV omits pack weights When a user exports workout history as CSV and relies on that export to retain or review session data, Include |
||
| } | ||
|
|
||
| static Future<void> _ensureSessionSchema(Database db) async { | ||
| await _addColumnIfMissing(db, 'sessions', 'steps', 'INTEGER'); | ||
| await _addColumnIfMissing(db, 'sessions', 'hrr_bpm', 'REAL'); | ||
|
|
@@ -6383,6 +6400,7 @@ class LocalDb { | |
| 'INTEGER NOT NULL DEFAULT 0', | ||
| ); | ||
| await _ensureSessionTraceColumns(db); | ||
| await _ensureSessionLoadColumns(db); | ||
| // Which workout sensors scored a session ([stampSessionSensor]), one row | ||
| // each: a strap serving both heart-rate services can hand the live | ||
| // source from one to the other mid-workout. A side table, not a | ||
|
|
@@ -16927,6 +16945,17 @@ class LocalDb { | |
| await db.update('sessions', {'rpe': rpe}, where: 'id = ?', whereArgs: [id]); | ||
| } | ||
|
|
||
| /// Set a session's carried weight. Its own UPDATE for the reason | ||
| /// [setSessionRpe] has one: `putSession` replaces the whole row. [bodyKg] is | ||
| /// written only when given, so correcting the pack weight on an old session | ||
| /// keeps the body weight that was banked with it. | ||
| static Future<void> setSessionLoad(String id, double? loadKg, | ||
| {double? bodyKg}) async { | ||
| final db = await instance; | ||
| await db.update('sessions', {'load_kg': loadKg, 'body_kg': ?bodyKg}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalidate VO₂max when a session becomes loaded. If a hike already has Clear or mask
|
||
| where: 'id = ?', whereArgs: [id]); | ||
| } | ||
|
|
||
| // NOTE: the in-app notifications feed (putNotification/notifications/ | ||
| // markNotificationsRead/unreadCount, + the `notifications` table) was | ||
| // removed — OS-level notifications (NotificationCenter.emit's | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ import '../ble/adapters/_registry.dart' show kBandRegistry; | |
| import 'local_repository.dart'; | ||
| import 'series_codec.dart'; | ||
| import '../gps/route_models.dart'; | ||
| import '../ui2/activity/catalogue.dart' show activityByName, loadCarried; | ||
| import '../gps/route_math.dart' as rmath; | ||
|
|
||
| class LocalRepositoryImpl extends LocalRepository { | ||
|
|
@@ -3557,8 +3558,17 @@ class LocalRepositoryImpl extends LocalRepository { | |
| // km split (a real known distance held over a real known duration) and | ||
| // never recomputed once banked, because the raw substrate it needs ages | ||
| // out in days while the split it was computed from does not change. | ||
| // | ||
| // Not for a session that carried weight. The estimate reads the speed | ||
| // as unloaded, and a pack raises the heart rate at any speed, so a ruck | ||
| // would bank a lower VO2max than the same person has. None is banked. | ||
| // The row's own weight counts too, so a ruck retyped to another activity | ||
| // stays out. | ||
| double? vo2max; | ||
| if ((row['vo2max_estimate'] as num?) == null && | ||
| !loadCarried | ||
| .contains(activityByName(row['type'] as String?)?.name) && | ||
| ((row['load_kg'] as num?) ?? 0) <= 0 && | ||
|
Comment on lines
+3569
to
+3571
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Previously banked VO₂max remains visible When a session has a banked VO₂max estimate before its type is changed to Rucking or a carried load is added, the new exclusion only prevents computing an estimate when the stored estimate is null. If a session already has an estimate before it is retyped as Rucking or given a carried load, the estimate remains in the row and continues to appear as though it describes an unloaded session. Clear or invalidate
Comment on lines
+3569
to
+3571
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · VO₂max change lacks version bump When rucking or carried-weight sessions reach VO₂max scoring, Bump From 4. **Bump `kAlgoVersion`** (`compute/derivation_engine.dart`) whenever any
analytics *output* changes, including via a sibling re-pin. Rows are immutable
per version; without a bump nothing recomputes. Add a changelog entry above
the constant.
5. **A bump citing a sibling change must be backed by the pin.** Verify the SHA
in `pubspec.yaml` actually contains the cited change. v43's changelog
described an analytics fix its pin never contained; the bug stayed live three
releases and only shipped at v46.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A pack-weight correction during the rescore pass can still bank a VO₂max estimate. The gate reads Make the write conditional on the session still having no load: Guard the VO₂max write on the stored load
The clause checks the stored value at write time. The Dart gate can still read the snapshot. The
|
||
| hrMaxForSession != null && | ||
| restingHrForSession != null) { | ||
| vo2max = await _submaxVo2maxFromSplits( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Retime drops a load correction
When a pack-weight correction lands after
_writeManualSessionrereads the session but before its replacement write,_writeManualSessioncan build its replacement row from a snapshot taken beforesetSessionLoadupdates the session; its laterputSessionthen replaces the row with the oldload_kgandbody_kg, so the correction disappears.Serialize retiming and load updates, or apply the edited load fields with a narrow update after the retime replacement.