deleteCompletedBefore method
Deletes all completed executions with updatedAt before cutoff.
Returns the number of executions deleted. Use this for periodic maintenance to prevent unbounded database growth.
Implementation
@override
Future<int> deleteCompletedBefore(DateTime cutoff) async {
final toDelete = _executions.values
.where((e) =>
e.status is Completed &&
DateTime.parse(e.updatedAt).isBefore(cutoff))
.map((e) => e.workflowExecutionId)
.toList();
for (final id in toDelete) {
await deleteExecution(id);
}
return toDelete.length;
}