Refactoring

This commit is contained in:
2026-05-05 11:42:34 +02:00
parent b9cfab1447
commit 9896008335
4 changed files with 8 additions and 6 deletions

View File

@@ -354,7 +354,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
/// Retrieves all matches associated with the given [groupId]. /// Retrieves all matches associated with the given [groupId].
/// Queries the database directly, filtering by [groupId]. /// Queries the database directly, filtering by [groupId].
Future<List<Match>> getGroupMatches({required String groupId}) async { Future<List<Match>> getMatchesByGroup({required String groupId}) async {
final query = select(matchTable)..where((m) => m.groupId.equals(groupId)); final query = select(matchTable)..where((m) => m.groupId.equals(groupId));
final rows = await query.get(); final rows = await query.get();

View File

@@ -197,7 +197,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
/// obsolete. For each such match, the group association is removed by setting /// obsolete. For each such match, the group association is removed by setting
/// its [groupId] to null. /// its [groupId] to null.
Future<void> deleteObsoleteMatchGroupRelations() async { Future<void> deleteObsoleteMatchGroupRelations() async {
final groupMatches = await db.matchDao.getGroupMatches( final groupMatches = await db.matchDao.getMatchesByGroup(
groupId: widget.groupToEdit!.id, groupId: widget.groupToEdit!.id,
); );

View File

@@ -244,7 +244,9 @@ class _GroupDetailViewState extends State<GroupDetailView> {
/// Loads statistics for this group /// Loads statistics for this group
Future<void> _loadStatistics() async { Future<void> _loadStatistics() async {
isLoading = true; isLoading = true;
final groupMatches = await db.matchDao.getGroupMatches(groupId: _group.id); final groupMatches = await db.matchDao.getMatchesByGroup(
groupId: _group.id,
);
setState(() { setState(() {
totalMatches = groupMatches.length; totalMatches = groupMatches.length;

View File

@@ -241,15 +241,15 @@ void main() {
expect(matchExists, isTrue); expect(matchExists, isTrue);
}); });
test('getGroupMatches() works correctly', () async { test('getMatchesByGroup() works correctly', () async {
var matches = await database.matchDao.getGroupMatches( var matches = await database.matchDao.getMatchesByGroup(
groupId: 'non-existing-id', groupId: 'non-existing-id',
); );
expect(matches, isEmpty); expect(matches, isEmpty);
await database.matchDao.addMatch(match: testMatch1); await database.matchDao.addMatch(match: testMatch1);
matches = await database.matchDao.getGroupMatches( matches = await database.matchDao.getMatchesByGroup(
groupId: testGroup1.id, groupId: testGroup1.id,
); );
expect(matches, isNotEmpty); expect(matches, isNotEmpty);