getTotalNumberOfTasks function
- dynamic firestore,
- String userId
Returns the total number of completed tasks by the given userId
.
Queries Firestore for all completed tasks associated with the user and returns the total count.
Implementation
Future<int> getTotalNumberOfTasks(
FirebaseFirestore firestore,
String userId,
) async {
final snapshot =
await firestore
.collection(tasksCollectionFieldName)
.where(ownerUserIdFieldName, isEqualTo: userId)
.where(isCompletedFieldName, isEqualTo: true)
.get();
return snapshot.docs.length;
}