Implementierung der Games #203
@@ -354,7 +354,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
|
|
||||||
|
sneeex marked this conversation as resolved
|
|||||||
/// 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();
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user
würde man das nicht eher in game dao packen? weil es geht doch um games und die damit assozierten matches und nicht andersrum, das steht auch im string da falsch
Nein, ich will die Anzahl an Matches mit einer spezifischen Game-ID. Ich frage ja auch den Match Table an, deswegen ists in der matchDao