Merge remote-tracking branch 'origin/development' into feature/206-Neuer-Regelsatz-Platzierung

# Conflicts:
#	lib/l10n/arb/app_de.arb
#	lib/l10n/arb/app_en.arb
#	lib/l10n/generated/app_localizations.dart
#	lib/l10n/generated/app_localizations_de.dart
#	lib/l10n/generated/app_localizations_en.dart
This commit is contained in:
2026-05-09 19:18:54 +02:00
29 changed files with 1752 additions and 411 deletions

View File

@@ -194,4 +194,25 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
final rowsAffected = await query.go();
return rowsAffected > 0;
}
/// Retrieves all games with their respective match counts.
/// Returns a list of tuples (Game, matchCount).
Future<List<(Game, int)>> getGameUsage() async {
final games = await getAllGames();
final results = <(Game, int)>[];
for (final game in games) {
final matchCount =
await (selectOnly(db.matchTable)
..where(db.matchTable.gameId.equals(game.id))
..addColumns([db.matchTable.id.count()]))
.map((row) => row.read(db.matchTable.id.count()))
.getSingle();
results.add((game, matchCount ?? 0));
}
return results;
}
}

View File

@@ -341,9 +341,20 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
);
}
/// Retrieves the number of matches associated with a specific game.
Future<int> getMatchCountByGame({required String gameId}) async {
final count =
await (selectOnly(matchTable)
..where(matchTable.gameId.equals(gameId))
..addColumns([matchTable.id.count()]))
.map((row) => row.read(matchTable.id.count()))
.getSingle();
return count ?? 0;
}
/// 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();
@@ -478,4 +489,12 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
final rowsAffected = await query.go();
return rowsAffected > 0;
}
/// Deletes all matches associated with a specific game.
/// Returns the number of matches deleted.
Future<int> deleteMatchesByGame({required String gameId}) async {
final query = delete(matchTable)..where((m) => m.gameId.equals(gameId));
final rowsAffected = await query.go();
return rowsAffected;
}
}

View File

@@ -12,16 +12,15 @@ class Game {
final String icon;
Game({
String? id,
DateTime? createdAt,
required this.name,
required this.ruleset,
String? description,
required this.color,
required this.icon,
this.color = GameColor.orange,
this.description = '',
this.icon = '',
String? id,
DateTime? createdAt,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(),
description = description ?? '';
createdAt = createdAt ?? clock.now();
@override
String toString() {