tasks method
Tasks, most-recently-updated first, optionally filtered.
Implementation
List<TaskInfo> tasks({
TaskState? state,
String? name,
String? queue,
String? worker,
int limit = 200,
int offset = 0,
}) {
final all = _tasks.values
.where((t) => state == null || t.state == state)
.where((t) => name == null || t.name == name)
.where((t) => queue == null || t.queue == queue)
.where((t) => worker == null || t.workerId == worker)
.toList()
..sort((a, b) => b.updatedAt.compareTo(a.updatedAt));
if (offset >= all.length) return const [];
return all.sublist(offset, (offset + limit).clamp(0, all.length));
}