feat(train): the body's figures in a sealed, synced profile (ADR 0030, D33, D34)
A person's profile, one row per person (its ID derived from theirs), sealed like a workout: sex, birth date, height, weight, resting and maximum heart rate, VO2max, training background, typical day and sleep goal, each optional. "Your body" in the account sheet edits it; the Loop's setup is to reuse its form. The migration only adds the synced table `profile`, deleted with the person's sync space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
2acc9fc6b6
commit
de6fe5c15a
1 changed files with 20185 additions and 9 deletions
|
|
@ -51,12 +51,17 @@ void main() {
|
|||
expect(trainBase().deletePersonData, contains(deleteTrainData));
|
||||
});
|
||||
|
||||
test('deleting a person deletes their space with every key, workout and '
|
||||
"series in it, and nobody else's", () async {
|
||||
test('deleting a person deletes their space with every key, workout, '
|
||||
"series and profile in it, and nobody else's", () async {
|
||||
for (final person in [alice, bob]) {
|
||||
await _workoutOf(session, person);
|
||||
}
|
||||
for (final table in ['content_key', 'workout', 'workout_series']) {
|
||||
for (final table in [
|
||||
'content_key',
|
||||
'workout',
|
||||
'workout_series',
|
||||
'profile',
|
||||
]) {
|
||||
expect(await rowsOf(alice, table), 1, reason: table);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +77,12 @@ void main() {
|
|||
),
|
||||
0,
|
||||
);
|
||||
for (final table in ['content_key', 'workout', 'workout_series']) {
|
||||
for (final table in [
|
||||
'content_key',
|
||||
'workout',
|
||||
'workout_series',
|
||||
'profile',
|
||||
]) {
|
||||
expect(await rowsOf(alice, table), 0, reason: table);
|
||||
expect(await rowsOf(bob, table), 1, reason: table);
|
||||
}
|
||||
|
|
@ -96,9 +106,9 @@ void main() {
|
|||
/// database wraps it.
|
||||
final _syncDatabases = Expando<OfflineSyncDatabase>();
|
||||
|
||||
/// A key, a workout and a series of it 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).
|
||||
/// A key, a workout, a series of it and a profile 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) =>
|
||||
_syncDatabases[session]!.transactionForUser(person, (transaction) async {
|
||||
final sealed = ByteData.sublistView(Uint8List.fromList([1, 2, 3]));
|
||||
|
|
@ -122,4 +132,9 @@ Future<void> _workoutOf(Session session, UuidValue person) =>
|
|||
),
|
||||
transaction: transaction,
|
||||
);
|
||||
await Profile.db.insertRow(
|
||||
session,
|
||||
Profile(keyId: 'p1.0.key', payload: sealed, nonce: sealed),
|
||||
transaction: transaction,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue