From 98960083350ef50d6cff3527261d9cb252a3076e Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Tue, 5 May 2026 11:42:34 +0200 Subject: [PATCH] Refactoring --- lib/data/dao/match_dao.dart | 2 +- .../views/main_menu/group_view/create_group_view.dart | 2 +- .../views/main_menu/group_view/group_detail_view.dart | 4 +++- test/db_tests/aggregates/match_test.dart | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/data/dao/match_dao.dart b/lib/data/dao/match_dao.dart index 340273d..88cca35 100644 --- a/lib/data/dao/match_dao.dart +++ b/lib/data/dao/match_dao.dart @@ -354,7 +354,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { /// Retrieves all matches associated with the given [groupId]. /// Queries the database directly, filtering by [groupId]. - Future> getGroupMatches({required String groupId}) async { + Future> getMatchesByGroup({required String groupId}) async { final query = select(matchTable)..where((m) => m.groupId.equals(groupId)); final rows = await query.get(); diff --git a/lib/presentation/views/main_menu/group_view/create_group_view.dart b/lib/presentation/views/main_menu/group_view/create_group_view.dart index 3a2ee60..b4a5b97 100644 --- a/lib/presentation/views/main_menu/group_view/create_group_view.dart +++ b/lib/presentation/views/main_menu/group_view/create_group_view.dart @@ -197,7 +197,7 @@ class _CreateGroupViewState extends State { /// obsolete. For each such match, the group association is removed by setting /// its [groupId] to null. Future deleteObsoleteMatchGroupRelations() async { - final groupMatches = await db.matchDao.getGroupMatches( + final groupMatches = await db.matchDao.getMatchesByGroup( groupId: widget.groupToEdit!.id, ); diff --git a/lib/presentation/views/main_menu/group_view/group_detail_view.dart b/lib/presentation/views/main_menu/group_view/group_detail_view.dart index 92c3bba..3d5e805 100644 --- a/lib/presentation/views/main_menu/group_view/group_detail_view.dart +++ b/lib/presentation/views/main_menu/group_view/group_detail_view.dart @@ -244,7 +244,9 @@ class _GroupDetailViewState extends State { /// Loads statistics for this group Future _loadStatistics() async { isLoading = true; - final groupMatches = await db.matchDao.getGroupMatches(groupId: _group.id); + final groupMatches = await db.matchDao.getMatchesByGroup( + groupId: _group.id, + ); setState(() { totalMatches = groupMatches.length; diff --git a/test/db_tests/aggregates/match_test.dart b/test/db_tests/aggregates/match_test.dart index 367f38f..2c9b768 100644 --- a/test/db_tests/aggregates/match_test.dart +++ b/test/db_tests/aggregates/match_test.dart @@ -241,15 +241,15 @@ void main() { expect(matchExists, isTrue); }); - test('getGroupMatches() works correctly', () async { - var matches = await database.matchDao.getGroupMatches( + test('getMatchesByGroup() works correctly', () async { + var matches = await database.matchDao.getMatchesByGroup( groupId: 'non-existing-id', ); expect(matches, isEmpty); await database.matchDao.addMatch(match: testMatch1); - matches = await database.matchDao.getGroupMatches( + matches = await database.matchDao.getMatchesByGroup( groupId: testGroup1.id, ); expect(matches, isNotEmpty);