feat(data): édition ponctuelle des séries en séance (ticket #21)

Étend le modèle Drift (tables.dart, app_database.dart/.g.dart) et la
couche application (entités, use cases, repositories) pour supporter
l'édition ponctuelle des séries pendant l'exécution d'une séance, sans
modifier le modèle/séance-modèle. build_runner OK, flutter analyze
propre, 30/30 tests verts, build APK debug validé.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-18 00:19:02 +02:00
parent 7eb8f260e0
commit abfbb64de2
7 changed files with 621 additions and 15 deletions

View File

@ -35,7 +35,7 @@ final class AppDatabase extends _$AppDatabase {
}
@override
int get schemaVersion => 1;
int get schemaVersion => 2;
@override
MigrationStrategy get migration {
@ -44,6 +44,19 @@ final class AppDatabase extends _$AppDatabase {
await migrator.createAll();
await _createIndexes();
},
onUpgrade: (migrator, from, to) async {
if (from < 2) {
await customStatement(
'ALTER TABLE active_set_results ADD COLUMN status TEXT NOT NULL '
"DEFAULT 'completed' CHECK (status IN ('completed', 'skipped'))",
);
await customStatement(
'ALTER TABLE workout_history_set_results ADD COLUMN status TEXT '
"NOT NULL DEFAULT 'completed' CHECK (status IN ('completed', "
"'skipped'))",
);
}
},
beforeOpen: (details) async {
await customStatement('PRAGMA foreign_keys = ON');
},

View File

@ -3578,6 +3578,16 @@ class $ActiveSetResultsTable extends ActiveSetResults
type: DriftSqlType.string,
requiredDuringInsert: false,
);
static const VerificationMeta _statusMeta = const VerificationMeta('status');
@override
late final GeneratedColumn<String> status = GeneratedColumn<String>(
'status',
aliasedName,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const Constant('completed'),
);
@override
List<GeneratedColumn> get $columns => [
id,
@ -3605,6 +3615,7 @@ class $ActiveSetResultsTable extends ActiveSetResults
scoreLabelSnapshot,
scoreUnitSnapshot,
note,
status,
];
@override
String get aliasedName => _alias ?? actualTableName;
@ -3837,6 +3848,12 @@ class $ActiveSetResultsTable extends ActiveSetResults
note.isAcceptableOrUnknown(data['note']!, _noteMeta),
);
}
if (data.containsKey('status')) {
context.handle(
_statusMeta,
status.isAcceptableOrUnknown(data['status']!, _statusMeta),
);
}
return context;
}
@ -3946,6 +3963,10 @@ class $ActiveSetResultsTable extends ActiveSetResults
DriftSqlType.string,
data['${effectivePrefix}note'],
),
status: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}status'],
)!,
);
}
@ -3981,6 +4002,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
final String? scoreLabelSnapshot;
final String? scoreUnitSnapshot;
final String? note;
final String status;
const ActiveSetResult({
required this.id,
required this.createdAt,
@ -4007,6 +4029,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
this.scoreLabelSnapshot,
this.scoreUnitSnapshot,
this.note,
required this.status,
});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
@ -4060,6 +4083,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
if (!nullToAbsent || note != null) {
map['note'] = Variable<String>(note);
}
map['status'] = Variable<String>(status);
return map;
}
@ -4112,6 +4136,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
? const Value.absent()
: Value(scoreUnitSnapshot),
note: note == null && nullToAbsent ? const Value.absent() : Value(note),
status: Value(status),
);
}
@ -4156,6 +4181,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
json['scoreUnitSnapshot'],
),
note: serializer.fromJson<String?>(json['note']),
status: serializer.fromJson<String>(json['status']),
);
}
@override
@ -4189,6 +4215,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
'scoreLabelSnapshot': serializer.toJson<String?>(scoreLabelSnapshot),
'scoreUnitSnapshot': serializer.toJson<String?>(scoreUnitSnapshot),
'note': serializer.toJson<String?>(note),
'status': serializer.toJson<String>(status),
};
}
@ -4218,6 +4245,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
Value<String?> scoreLabelSnapshot = const Value.absent(),
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<String?> note = const Value.absent(),
String? status,
}) => ActiveSetResult(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
@ -4253,6 +4281,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
? scoreUnitSnapshot.value
: this.scoreUnitSnapshot,
note: note.present ? note.value : this.note,
status: status ?? this.status,
);
ActiveSetResult copyWithCompanion(ActiveSetResultsCompanion data) {
return ActiveSetResult(
@ -4315,6 +4344,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
? data.scoreUnitSnapshot.value
: this.scoreUnitSnapshot,
note: data.note.present ? data.note.value : this.note,
status: data.status.present ? data.status.value : this.status,
);
}
@ -4345,7 +4375,8 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
..write('actualScore: $actualScore, ')
..write('scoreLabelSnapshot: $scoreLabelSnapshot, ')
..write('scoreUnitSnapshot: $scoreUnitSnapshot, ')
..write('note: $note')
..write('note: $note, ')
..write('status: $status')
..write(')'))
.toString();
}
@ -4377,6 +4408,7 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
scoreLabelSnapshot,
scoreUnitSnapshot,
note,
status,
]);
@override
bool operator ==(Object other) =>
@ -4406,7 +4438,8 @@ class ActiveSetResult extends DataClass implements Insertable<ActiveSetResult> {
other.actualScore == this.actualScore &&
other.scoreLabelSnapshot == this.scoreLabelSnapshot &&
other.scoreUnitSnapshot == this.scoreUnitSnapshot &&
other.note == this.note);
other.note == this.note &&
other.status == this.status);
}
class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
@ -4435,6 +4468,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
final Value<String?> scoreLabelSnapshot;
final Value<String?> scoreUnitSnapshot;
final Value<String?> note;
final Value<String> status;
final Value<int> rowid;
const ActiveSetResultsCompanion({
this.id = const Value.absent(),
@ -4462,6 +4496,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
this.scoreLabelSnapshot = const Value.absent(),
this.scoreUnitSnapshot = const Value.absent(),
this.note = const Value.absent(),
this.status = const Value.absent(),
this.rowid = const Value.absent(),
});
ActiveSetResultsCompanion.insert({
@ -4490,6 +4525,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
this.scoreLabelSnapshot = const Value.absent(),
this.scoreUnitSnapshot = const Value.absent(),
this.note = const Value.absent(),
this.status = const Value.absent(),
this.rowid = const Value.absent(),
}) : id = Value(id),
createdAt = Value(createdAt),
@ -4529,6 +4565,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
Expression<String>? scoreLabelSnapshot,
Expression<String>? scoreUnitSnapshot,
Expression<String>? note,
Expression<String>? status,
Expression<int>? rowid,
}) {
return RawValuesInsertable({
@ -4561,6 +4598,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
'score_label_snapshot': scoreLabelSnapshot,
if (scoreUnitSnapshot != null) 'score_unit_snapshot': scoreUnitSnapshot,
if (note != null) 'note': note,
if (status != null) 'status': status,
if (rowid != null) 'rowid': rowid,
});
}
@ -4591,6 +4629,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
Value<String?>? scoreLabelSnapshot,
Value<String?>? scoreUnitSnapshot,
Value<String?>? note,
Value<String>? status,
Value<int>? rowid,
}) {
return ActiveSetResultsCompanion(
@ -4620,6 +4659,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
scoreLabelSnapshot: scoreLabelSnapshot ?? this.scoreLabelSnapshot,
scoreUnitSnapshot: scoreUnitSnapshot ?? this.scoreUnitSnapshot,
note: note ?? this.note,
status: status ?? this.status,
rowid: rowid ?? this.rowid,
);
}
@ -4706,6 +4746,9 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
if (note.present) {
map['note'] = Variable<String>(note.value);
}
if (status.present) {
map['status'] = Variable<String>(status.value);
}
if (rowid.present) {
map['rowid'] = Variable<int>(rowid.value);
}
@ -4740,6 +4783,7 @@ class ActiveSetResultsCompanion extends UpdateCompanion<ActiveSetResult> {
..write('scoreLabelSnapshot: $scoreLabelSnapshot, ')
..write('scoreUnitSnapshot: $scoreUnitSnapshot, ')
..write('note: $note, ')
..write('status: $status, ')
..write('rowid: $rowid')
..write(')'))
.toString();
@ -12033,6 +12077,16 @@ class $WorkoutHistorySetResultsTable extends WorkoutHistorySetResults
type: DriftSqlType.dateTime,
requiredDuringInsert: false,
);
static const VerificationMeta _statusMeta = const VerificationMeta('status');
@override
late final GeneratedColumn<String> status = GeneratedColumn<String>(
'status',
aliasedName,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const Constant('completed'),
);
@override
List<GeneratedColumn> get $columns => [
id,
@ -12067,6 +12121,7 @@ class $WorkoutHistorySetResultsTable extends WorkoutHistorySetResults
scoreUnitSnapshot,
startedAt,
completedAt,
status,
];
@override
String get aliasedName => _alias ?? actualTableName;
@ -12375,6 +12430,12 @@ class $WorkoutHistorySetResultsTable extends WorkoutHistorySetResults
),
);
}
if (data.containsKey('status')) {
context.handle(
_statusMeta,
status.isAcceptableOrUnknown(data['status']!, _statusMeta),
);
}
return context;
}
@ -12515,6 +12576,10 @@ class $WorkoutHistorySetResultsTable extends WorkoutHistorySetResults
DriftSqlType.dateTime,
data['${effectivePrefix}completed_at'],
),
status: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}status'],
)!,
);
}
@ -12558,6 +12623,7 @@ class WorkoutHistorySetResult extends DataClass
final String? scoreUnitSnapshot;
final DateTime? startedAt;
final DateTime? completedAt;
final String status;
const WorkoutHistorySetResult({
required this.id,
required this.createdAt,
@ -12591,6 +12657,7 @@ class WorkoutHistorySetResult extends DataClass
this.scoreUnitSnapshot,
this.startedAt,
this.completedAt,
required this.status,
});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
@ -12657,6 +12724,7 @@ class WorkoutHistorySetResult extends DataClass
if (!nullToAbsent || completedAt != null) {
map['completed_at'] = Variable<DateTime>(completedAt);
}
map['status'] = Variable<String>(status);
return map;
}
@ -12723,6 +12791,7 @@ class WorkoutHistorySetResult extends DataClass
completedAt: completedAt == null && nullToAbsent
? const Value.absent()
: Value(completedAt),
status: Value(status),
);
}
@ -12786,6 +12855,7 @@ class WorkoutHistorySetResult extends DataClass
),
startedAt: serializer.fromJson<DateTime?>(json['startedAt']),
completedAt: serializer.fromJson<DateTime?>(json['completedAt']),
status: serializer.fromJson<String>(json['status']),
);
}
@override
@ -12826,6 +12896,7 @@ class WorkoutHistorySetResult extends DataClass
'scoreUnitSnapshot': serializer.toJson<String?>(scoreUnitSnapshot),
'startedAt': serializer.toJson<DateTime?>(startedAt),
'completedAt': serializer.toJson<DateTime?>(completedAt),
'status': serializer.toJson<String>(status),
};
}
@ -12862,6 +12933,7 @@ class WorkoutHistorySetResult extends DataClass
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<DateTime?> startedAt = const Value.absent(),
Value<DateTime?> completedAt = const Value.absent(),
String? status,
}) => WorkoutHistorySetResult(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
@ -12909,6 +12981,7 @@ class WorkoutHistorySetResult extends DataClass
: this.scoreUnitSnapshot,
startedAt: startedAt.present ? startedAt.value : this.startedAt,
completedAt: completedAt.present ? completedAt.value : this.completedAt,
status: status ?? this.status,
);
WorkoutHistorySetResult copyWithCompanion(
WorkoutHistorySetResultsCompanion data,
@ -12996,6 +13069,7 @@ class WorkoutHistorySetResult extends DataClass
completedAt: data.completedAt.present
? data.completedAt.value
: this.completedAt,
status: data.status.present ? data.status.value : this.status,
);
}
@ -13033,7 +13107,8 @@ class WorkoutHistorySetResult extends DataClass
..write('scoreLabelSnapshot: $scoreLabelSnapshot, ')
..write('scoreUnitSnapshot: $scoreUnitSnapshot, ')
..write('startedAt: $startedAt, ')
..write('completedAt: $completedAt')
..write('completedAt: $completedAt, ')
..write('status: $status')
..write(')'))
.toString();
}
@ -13072,6 +13147,7 @@ class WorkoutHistorySetResult extends DataClass
scoreUnitSnapshot,
startedAt,
completedAt,
status,
]);
@override
bool operator ==(Object other) =>
@ -13108,7 +13184,8 @@ class WorkoutHistorySetResult extends DataClass
other.scoreLabelSnapshot == this.scoreLabelSnapshot &&
other.scoreUnitSnapshot == this.scoreUnitSnapshot &&
other.startedAt == this.startedAt &&
other.completedAt == this.completedAt);
other.completedAt == this.completedAt &&
other.status == this.status);
}
class WorkoutHistorySetResultsCompanion
@ -13145,6 +13222,7 @@ class WorkoutHistorySetResultsCompanion
final Value<String?> scoreUnitSnapshot;
final Value<DateTime?> startedAt;
final Value<DateTime?> completedAt;
final Value<String> status;
final Value<int> rowid;
const WorkoutHistorySetResultsCompanion({
this.id = const Value.absent(),
@ -13179,6 +13257,7 @@ class WorkoutHistorySetResultsCompanion
this.scoreUnitSnapshot = const Value.absent(),
this.startedAt = const Value.absent(),
this.completedAt = const Value.absent(),
this.status = const Value.absent(),
this.rowid = const Value.absent(),
});
WorkoutHistorySetResultsCompanion.insert({
@ -13214,6 +13293,7 @@ class WorkoutHistorySetResultsCompanion
this.scoreUnitSnapshot = const Value.absent(),
this.startedAt = const Value.absent(),
this.completedAt = const Value.absent(),
this.status = const Value.absent(),
this.rowid = const Value.absent(),
}) : id = Value(id),
createdAt = Value(createdAt),
@ -13265,6 +13345,7 @@ class WorkoutHistorySetResultsCompanion
Expression<String>? scoreUnitSnapshot,
Expression<DateTime>? startedAt,
Expression<DateTime>? completedAt,
Expression<String>? status,
Expression<int>? rowid,
}) {
return RawValuesInsertable({
@ -13311,6 +13392,7 @@ class WorkoutHistorySetResultsCompanion
if (scoreUnitSnapshot != null) 'score_unit_snapshot': scoreUnitSnapshot,
if (startedAt != null) 'started_at': startedAt,
if (completedAt != null) 'completed_at': completedAt,
if (status != null) 'status': status,
if (rowid != null) 'rowid': rowid,
});
}
@ -13348,6 +13430,7 @@ class WorkoutHistorySetResultsCompanion
Value<String?>? scoreUnitSnapshot,
Value<DateTime?>? startedAt,
Value<DateTime?>? completedAt,
Value<String>? status,
Value<int>? rowid,
}) {
return WorkoutHistorySetResultsCompanion(
@ -13384,6 +13467,7 @@ class WorkoutHistorySetResultsCompanion
scoreUnitSnapshot: scoreUnitSnapshot ?? this.scoreUnitSnapshot,
startedAt: startedAt ?? this.startedAt,
completedAt: completedAt ?? this.completedAt,
status: status ?? this.status,
rowid: rowid ?? this.rowid,
);
}
@ -13499,6 +13583,9 @@ class WorkoutHistorySetResultsCompanion
if (completedAt.present) {
map['completed_at'] = Variable<DateTime>(completedAt.value);
}
if (status.present) {
map['status'] = Variable<String>(status.value);
}
if (rowid.present) {
map['rowid'] = Variable<int>(rowid.value);
}
@ -13540,6 +13627,7 @@ class WorkoutHistorySetResultsCompanion
..write('scoreUnitSnapshot: $scoreUnitSnapshot, ')
..write('startedAt: $startedAt, ')
..write('completedAt: $completedAt, ')
..write('status: $status, ')
..write('rowid: $rowid')
..write(')'))
.toString();
@ -18114,6 +18202,7 @@ typedef $$ActiveSetResultsTableCreateCompanionBuilder =
Value<String?> scoreLabelSnapshot,
Value<String?> scoreUnitSnapshot,
Value<String?> note,
Value<String> status,
Value<int> rowid,
});
typedef $$ActiveSetResultsTableUpdateCompanionBuilder =
@ -18143,6 +18232,7 @@ typedef $$ActiveSetResultsTableUpdateCompanionBuilder =
Value<String?> scoreLabelSnapshot,
Value<String?> scoreUnitSnapshot,
Value<String?> note,
Value<String> status,
Value<int> rowid,
});
@ -18307,6 +18397,11 @@ class $$ActiveSetResultsTableFilterComposer
builder: (column) => ColumnFilters(column),
);
ColumnFilters<String> get status => $composableBuilder(
column: $table.status,
builder: (column) => ColumnFilters(column),
);
$$ActiveWorkoutSessionsTableFilterComposer get activeWorkoutSessionId {
final $$ActiveWorkoutSessionsTableFilterComposer composer =
$composerBuilder(
@ -18461,6 +18556,11 @@ class $$ActiveSetResultsTableOrderingComposer
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get status => $composableBuilder(
column: $table.status,
builder: (column) => ColumnOrderings(column),
);
$$ActiveWorkoutSessionsTableOrderingComposer get activeWorkoutSessionId {
final $$ActiveWorkoutSessionsTableOrderingComposer composer =
$composerBuilder(
@ -18599,6 +18699,9 @@ class $$ActiveSetResultsTableAnnotationComposer
GeneratedColumn<String> get note =>
$composableBuilder(column: $table.note, builder: (column) => column);
GeneratedColumn<String> get status =>
$composableBuilder(column: $table.status, builder: (column) => column);
$$ActiveWorkoutSessionsTableAnnotationComposer get activeWorkoutSessionId {
final $$ActiveWorkoutSessionsTableAnnotationComposer composer =
$composerBuilder(
@ -18679,6 +18782,7 @@ class $$ActiveSetResultsTableTableManager
Value<String?> scoreLabelSnapshot = const Value.absent(),
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<String?> note = const Value.absent(),
Value<String> status = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => ActiveSetResultsCompanion(
id: id,
@ -18706,6 +18810,7 @@ class $$ActiveSetResultsTableTableManager
scoreLabelSnapshot: scoreLabelSnapshot,
scoreUnitSnapshot: scoreUnitSnapshot,
note: note,
status: status,
rowid: rowid,
),
createCompanionCallback:
@ -18735,6 +18840,7 @@ class $$ActiveSetResultsTableTableManager
Value<String?> scoreLabelSnapshot = const Value.absent(),
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<String?> note = const Value.absent(),
Value<String> status = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => ActiveSetResultsCompanion.insert(
id: id,
@ -18762,6 +18868,7 @@ class $$ActiveSetResultsTableTableManager
scoreLabelSnapshot: scoreLabelSnapshot,
scoreUnitSnapshot: scoreUnitSnapshot,
note: note,
status: status,
rowid: rowid,
),
withReferenceMapper: (p0) => p0
@ -23550,6 +23657,7 @@ typedef $$WorkoutHistorySetResultsTableCreateCompanionBuilder =
Value<String?> scoreUnitSnapshot,
Value<DateTime?> startedAt,
Value<DateTime?> completedAt,
Value<String> status,
Value<int> rowid,
});
typedef $$WorkoutHistorySetResultsTableUpdateCompanionBuilder =
@ -23586,6 +23694,7 @@ typedef $$WorkoutHistorySetResultsTableUpdateCompanionBuilder =
Value<String?> scoreUnitSnapshot,
Value<DateTime?> startedAt,
Value<DateTime?> completedAt,
Value<String> status,
Value<int> rowid,
});
@ -23786,6 +23895,11 @@ class $$WorkoutHistorySetResultsTableFilterComposer
builder: (column) => ColumnFilters(column),
);
ColumnFilters<String> get status => $composableBuilder(
column: $table.status,
builder: (column) => ColumnFilters(column),
);
$$WorkoutHistoriesTableFilterComposer get workoutHistoryId {
final $$WorkoutHistoriesTableFilterComposer composer = $composerBuilder(
composer: this,
@ -23974,6 +24088,11 @@ class $$WorkoutHistorySetResultsTableOrderingComposer
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get status => $composableBuilder(
column: $table.status,
builder: (column) => ColumnOrderings(column),
);
$$WorkoutHistoriesTableOrderingComposer get workoutHistoryId {
final $$WorkoutHistoriesTableOrderingComposer composer = $composerBuilder(
composer: this,
@ -24148,6 +24267,9 @@ class $$WorkoutHistorySetResultsTableAnnotationComposer
builder: (column) => column,
);
GeneratedColumn<String> get status =>
$composableBuilder(column: $table.status, builder: (column) => column);
$$WorkoutHistoriesTableAnnotationComposer get workoutHistoryId {
final $$WorkoutHistoriesTableAnnotationComposer composer = $composerBuilder(
composer: this,
@ -24243,6 +24365,7 @@ class $$WorkoutHistorySetResultsTableTableManager
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<DateTime?> startedAt = const Value.absent(),
Value<DateTime?> completedAt = const Value.absent(),
Value<String> status = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => WorkoutHistorySetResultsCompanion(
id: id,
@ -24277,6 +24400,7 @@ class $$WorkoutHistorySetResultsTableTableManager
scoreUnitSnapshot: scoreUnitSnapshot,
startedAt: startedAt,
completedAt: completedAt,
status: status,
rowid: rowid,
),
createCompanionCallback:
@ -24313,6 +24437,7 @@ class $$WorkoutHistorySetResultsTableTableManager
Value<String?> scoreUnitSnapshot = const Value.absent(),
Value<DateTime?> startedAt = const Value.absent(),
Value<DateTime?> completedAt = const Value.absent(),
Value<String> status = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => WorkoutHistorySetResultsCompanion.insert(
id: id,
@ -24347,6 +24472,7 @@ class $$WorkoutHistorySetResultsTableTableManager
scoreUnitSnapshot: scoreUnitSnapshot,
startedAt: startedAt,
completedAt: completedAt,
status: status,
rowid: rowid,
),
withReferenceMapper: (p0) => p0

View File

@ -929,6 +929,7 @@ db.ActiveSetResultsCompanion _activeSetResultCompanion(
scoreLabelSnapshot: Value(result.scoreLabelSnapshot),
scoreUnitSnapshot: Value(result.scoreUnitSnapshot),
note: Value(result.note),
status: Value(_setResultStatusToDb(result.status)),
);
}
@ -949,6 +950,7 @@ domain.ActiveSetResult _activeSetResultFromRow(db.ActiveSetResult row) {
scoreLabelSnapshot: row.scoreLabelSnapshot,
scoreUnitSnapshot: row.scoreUnitSnapshot,
note: row.note,
status: _setResultStatusFromDb(row.status),
);
}
@ -1059,6 +1061,7 @@ db.WorkoutHistorySetResultsCompanion _workoutHistorySetResultCompanion(
scoreUnitSnapshot: Value(result.scoreUnitSnapshot),
startedAt: Value(result.startedAt),
completedAt: Value(result.completedAt),
status: Value(_setResultStatusToDb(result.status)),
);
}
@ -1106,6 +1109,7 @@ domain.WorkoutHistorySetResult _workoutHistorySetResultFromRow(
scoreUnitSnapshot: row.scoreUnitSnapshot,
startedAt: row.startedAt,
completedAt: row.completedAt,
status: _setResultStatusFromDb(row.status),
);
}
@ -1143,6 +1147,17 @@ domain.MediaKind _mediaKindFromDb(String value) => switch (value) {
_ => throw domain.DomainException('Unknown media kind: $value'),
};
String _setResultStatusToDb(domain.SetResultStatus status) => switch (status) {
domain.SetResultStatus.completed => 'completed',
domain.SetResultStatus.skipped => 'skipped',
};
domain.SetResultStatus _setResultStatusFromDb(String value) => switch (value) {
'completed' => domain.SetResultStatus.completed,
'skipped' => domain.SetResultStatus.skipped,
_ => throw domain.DomainException('Unknown set result status: $value'),
};
domain.ActiveWorkoutStatus _activeStatusFromDb(String value) => switch (value) {
'running' => domain.ActiveWorkoutStatus.running,
'paused' => domain.ActiveWorkoutStatus.paused,

View File

@ -244,6 +244,7 @@ class ActiveSetResults extends SyncableTable {
TextColumn get scoreLabelSnapshot => text().nullable()();
TextColumn get scoreUnitSnapshot => text().nullable()();
TextColumn get note => text().nullable()();
TextColumn get status => text().withDefault(const Constant('completed'))();
@override
List<String> get customConstraints => [
@ -255,6 +256,9 @@ class ActiveSetResults extends SyncableTable {
'CHECK (actual_time_ms IS NULL OR actual_time_ms >= 0)',
'CHECK (actual_reps IS NULL OR actual_reps >= 0)',
'CHECK (actual_score IS NULL OR actual_score >= 0)',
"CHECK (status IN ('completed', 'skipped'))",
'CHECK (status != \'skipped\' OR (actual_time_ms IS NULL '
'AND actual_reps IS NULL AND actual_score IS NULL))',
'CHECK (actual_score IS NULL OR (score_label_snapshot IS NOT NULL '
'AND length(trim(score_label_snapshot)) > 0 '
'AND score_unit_snapshot IS NOT NULL '
@ -332,6 +336,7 @@ class WorkoutHistorySetResults extends SyncableTable {
TextColumn get scoreUnitSnapshot => text().nullable()();
DateTimeColumn get startedAt => dateTime().nullable()();
DateTimeColumn get completedAt => dateTime().nullable()();
TextColumn get status => text().withDefault(const Constant('completed'))();
@override
List<String> get customConstraints => [
@ -349,6 +354,9 @@ class WorkoutHistorySetResults extends SyncableTable {
'CHECK (actual_time_ms IS NULL OR actual_time_ms >= 0)',
'CHECK (actual_reps IS NULL OR actual_reps >= 0)',
'CHECK (actual_score IS NULL OR actual_score >= 0)',
"CHECK (status IN ('completed', 'skipped'))",
'CHECK (status != \'skipped\' OR (actual_time_ms IS NULL '
'AND actual_reps IS NULL AND actual_score IS NULL))',
'CHECK (actual_score IS NULL OR (score_label_snapshot IS NOT NULL '
'AND length(trim(score_label_snapshot)) > 0 '
'AND score_unit_snapshot IS NOT NULL '