deleteCompletedBefore method

  1. @override
Future<int> deleteCompletedBefore(
  1. DateTime cutoff
)
override

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;
}