@@ -26,11 +26,15 @@ class DashboardSummaryService {
26
26
/// This method fetches the counts of all items from the required
27
27
/// repositories and constructs a [DashboardSummary] object.
28
28
Future <DashboardSummary > getSummary () async {
29
+ // Define a filter to count only documents with an 'active' status.
30
+ // Using the enum's `name` property ensures type safety and consistency.
31
+ final activeFilter = {'status' : ContentStatus .active.name};
32
+
29
33
// Use Future.wait to fetch all counts in parallel for efficiency.
30
34
final results = await Future .wait ([
31
- _headlineRepository.count (),
32
- _topicRepository.count (),
33
- _sourceRepository.count (),
35
+ _headlineRepository.count (filter : activeFilter ),
36
+ _topicRepository.count (filter : activeFilter ),
37
+ _sourceRepository.count (filter : activeFilter ),
34
38
]);
35
39
36
40
// The results are integers.
@@ -39,7 +43,7 @@ class DashboardSummaryService {
39
43
final sourceCount = results[2 ];
40
44
41
45
return DashboardSummary (
42
- id: 'dashboard_summary' , // Fixed ID for the singleton summary
46
+ id: 'dashboard_summary' ,
43
47
headlineCount: headlineCount,
44
48
topicCount: topicCount,
45
49
sourceCount: sourceCount,
0 commit comments