StatusAggregate.fromTasks constructor
- Iterable<
MoodleTask> tasks
Creates a StatusAggregate from a set of tasks.
Implementation
factory StatusAggregate.fromTasks(Iterable<MoodleTask> tasks) {
final done = tasks.where((t) => t.status == MoodleTaskStatus.done).length;
final pending = tasks.where((t) => t.status == MoodleTaskStatus.pending).length;
final uploaded = tasks.where((t) => t.status == MoodleTaskStatus.uploaded).length;
final late = tasks.where((t) => t.status == MoodleTaskStatus.late).length;
return StatusAggregate(done: done, pending: pending, uploaded: uploaded, late: late);
}