Skip to content

Commit 2832ed5

Browse files
committed
refactor(dashboard): replace Category with Topic in DashboardSummaryService
- Update DashboardSummaryService to use HtDataRepository<Topic> instead of HtDataRepository<Category> - Modify the service to fetch topics instead of categories - Update the returned DashboardSummary to use topicCount instead of categoryCount
1 parent f038b3a commit 2832ed5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/src/services/dashboard_summary_service.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class DashboardSummaryService {
1111
/// {@macro dashboard_summary_service}
1212
const DashboardSummaryService({
1313
required HtDataRepository<Headline> headlineRepository,
14-
required HtDataRepository<Category> categoryRepository,
14+
required HtDataRepository<Topic> topicRepository,
1515
required HtDataRepository<Source> sourceRepository,
1616
}) : _headlineRepository = headlineRepository,
17-
_categoryRepository = categoryRepository,
17+
_topicRepository = topicRepository,
1818
_sourceRepository = sourceRepository;
1919

2020
final HtDataRepository<Headline> _headlineRepository;
21-
final HtDataRepository<Category> _categoryRepository;
21+
final HtDataRepository<Topic> _topicRepository;
2222
final HtDataRepository<Source> _sourceRepository;
2323

2424
/// Calculates and returns the current dashboard summary.
@@ -29,19 +29,19 @@ class DashboardSummaryService {
2929
// Use Future.wait to fetch all counts in parallel for efficiency.
3030
final results = await Future.wait([
3131
_headlineRepository.readAll(),
32-
_categoryRepository.readAll(),
32+
_topicRepository.readAll(),
3333
_sourceRepository.readAll(),
3434
]);
3535

3636
// The results are PaginatedResponse objects.
3737
final headlineResponse = results[0] as PaginatedResponse<Headline>;
38-
final categoryResponse = results[1] as PaginatedResponse<Category>;
38+
final topicResponse = results[1] as PaginatedResponse<Topic>;
3939
final sourceResponse = results[2] as PaginatedResponse<Source>;
4040

4141
return DashboardSummary(
4242
id: 'dashboard_summary', // Fixed ID for the singleton summary
4343
headlineCount: headlineResponse.items.length,
44-
categoryCount: categoryResponse.items.length,
44+
topicCount: topicResponse.items.length,
4545
sourceCount: sourceResponse.items.length,
4646
);
4747
}

0 commit comments

Comments
 (0)