Skip to content

Commit c3c1108

Browse files
committed
feat(service): add filter for active status in dashboard summary counts
1 parent 66ebf13 commit c3c1108

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/src/services/dashboard_summary_service.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ class DashboardSummaryService {
2626
/// This method fetches the counts of all items from the required
2727
/// repositories and constructs a [DashboardSummary] object.
2828
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+
2933
// Use Future.wait to fetch all counts in parallel for efficiency.
3034
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),
3438
]);
3539

3640
// The results are integers.
@@ -39,7 +43,7 @@ class DashboardSummaryService {
3943
final sourceCount = results[2];
4044

4145
return DashboardSummary(
42-
id: 'dashboard_summary', // Fixed ID for the singleton summary
46+
id: 'dashboard_summary',
4347
headlineCount: headlineCount,
4448
topicCount: topicCount,
4549
sourceCount: sourceCount,

0 commit comments

Comments
 (0)