Refactoring
This commit is contained in:
@@ -354,7 +354,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
|
||||
/// Retrieves all matches associated with the given [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 rows = await query.get();
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
||||
/// obsolete. For each such match, the group association is removed by setting
|
||||
/// its [groupId] to null.
|
||||
Future<void> deleteObsoleteMatchGroupRelations() async {
|
||||
final groupMatches = await db.matchDao.getGroupMatches(
|
||||
final groupMatches = await db.matchDao.getMatchesByGroup(
|
||||
groupId: widget.groupToEdit!.id,
|
||||
);
|
||||
|
||||
|
||||
@@ -244,7 +244,9 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
||||
/// Loads statistics for this group
|
||||
Future<void> _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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user