feat(train): equipment by place and a plate calculator (ADR 0034)

The places a person trains at (home, a gym), each a sealed, synced
`training_place` row with its equipment: bars and handles with their own
weight, plates by weight and count, dumbbells and kettlebells, the rest
by count, the person's own by name. A new place starts from what a home
or a gym usually has. The place last chosen is remembered on the device,
never its location.

The plate calculator loads each weight both sides alike, the heaviest
load not above it with the fewest plates, heavier inside, and over a
series of sets picks the loads making the fewest plate moves, listing
what comes off and goes on. Equipment is in Settings; strength plans
are to build on it.

The migration only creates the table, its space index and its cascade
to the sync engine's spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-02 11:59:24 +01:00
commit 064b911aa2
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -53,8 +53,8 @@ void main() {
test(
'deleting a person deletes their space with every key, workout, '
"series, profile, day, day's series, night, plan and route in it, and "
"nobody else's",
"series, profile, day, day's series, night, plan, route and training "
"place in it, and nobody else's",
() async {
for (final person in [alice, bob]) {
await _workoutOf(session, person);
@ -69,6 +69,7 @@ void main() {
'night',
'plan',
'route',
'training_place',
]) {
expect(await rowsOf(alice, table), 1, reason: table);
}
@ -95,6 +96,7 @@ void main() {
'night',
'plan',
'route',
'training_place',
]) {
expect(await rowsOf(alice, table), 0, reason: table);
expect(await rowsOf(bob, table), 1, reason: table);
@ -121,7 +123,7 @@ void main() {
final _syncDatabases = Expando<OfflineSyncDatabase>();
/// A key, a workout, a series of it, a profile, a day, a series of it, a
/// night, a plan and a route in [person]'s personal space, written as their
/// night, a plan, a route and a training place in [person]'s personal space, written as their
/// device would through the sync engine (payloads stand in for sealed ones: the server never reads
/// them).
Future<void> _workoutOf(Session session, UuidValue person) =>
@ -182,4 +184,9 @@ Future<void> _workoutOf(Session session, UuidValue person) =>
SavedRoute(keyId: 'p1.0.key', payload: sealed, nonce: sealed),
transaction: transaction,
);
await TrainingPlace.db.insertRow(
session,
TrainingPlace(keyId: 'p1.0.key', payload: sealed, nonce: sealed),
transaction: transaction,
);
});