Renamed methods for better distinction

This commit is contained in:
2025-11-26 14:42:17 +01:00
parent 499415e0c5
commit 2a34243e69
8 changed files with 11 additions and 11 deletions

View File

@@ -79,7 +79,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
); );
if (game.players != null) { if (game.players != null) {
await db.playerDao.addPlayers(players: game.players!); await db.playerDao.addPlayersAsList(players: game.players!);
for (final p in game.players ?? []) { for (final p in game.players ?? []) {
await db.playerGameDao.addPlayerToGame( await db.playerGameDao.addPlayerToGame(
gameId: game.id, gameId: game.id,
@@ -102,7 +102,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
/// Also adds associated players and groups if they exist. /// Also adds associated players and groups if they exist.
/// If the [games] list is empty, the method returns immediately. /// If the [games] list is empty, the method returns immediately.
/// If a game, player, or group already exists, it will be replaced. /// If a game, player, or group already exists, it will be replaced.
Future<void> addGames({required List<Game> games}) async { Future<void> addGamesAsList({required List<Game> games}) async {
if (games.isEmpty) return; if (games.isEmpty) return;
await db.transaction(() async { await db.transaction(() async {
// Add all games in batch // Add all games in batch

View File

@@ -84,7 +84,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
/// Adds multiple groups to the database. /// Adds multiple groups to the database.
/// Also adds the group's members to the [PlayerGroupTable]. /// Also adds the group's members to the [PlayerGroupTable].
Future<void> addGroups({required List<Group> groups}) async { Future<void> addGroupsAsList({required List<Group> groups}) async {
if (groups.isEmpty) return; if (groups.isEmpty) return;
await db.transaction(() async { await db.transaction(() async {
// Deduplicate groups by id - keep first occurrence // Deduplicate groups by id - keep first occurrence

View File

@@ -50,7 +50,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
} }
/// Adds multiple [players] to the database in a batch operation. /// Adds multiple [players] to the database in a batch operation.
Future<bool> addPlayers({required List<Player> players}) async { Future<bool> addPlayersAsList({required List<Player> players}) async {
if (players.isEmpty) return false; if (players.isEmpty) return false;
await db.batch( await db.batch(

View File

@@ -110,9 +110,9 @@ class DataTransferService {
.toList() ?? .toList() ??
[]; [];
await db.playerDao.addPlayers(players: importedPlayers); await db.playerDao.addPlayersAsList(players: importedPlayers);
await db.groupDao.addGroups(groups: importedGroups); await db.groupDao.addGroupsAsList(groups: importedGroups);
await db.gameDao.addGames(games: importedGames); await db.gameDao.addGamesAsList(games: importedGames);
} else { } else {
return ImportResult.invalidSchema; return ImportResult.invalidSchema;
} }

View File

@@ -112,7 +112,7 @@ void main() {
}); });
test('Adding and fetching multiple games works correctly', () async { test('Adding and fetching multiple games works correctly', () async {
await database.gameDao.addGames( await database.gameDao.addGamesAsList(
games: [testGame1, testGame2, testGameOnlyGroup, testGameOnlyPlayers], games: [testGame1, testGame2, testGameOnlyGroup, testGameOnlyPlayers],
); );

View File

@@ -81,7 +81,7 @@ void main() {
}); });
test('Adding and fetching multiple groups works correctly', () async { test('Adding and fetching multiple groups works correctly', () async {
await database.groupDao.addGroups( await database.groupDao.addGroupsAsList(
groups: [testGroup1, testGroup2, testGroup3, testGroup4], groups: [testGroup1, testGroup2, testGroup3, testGroup4],
); );

View File

@@ -141,7 +141,7 @@ void main() {
await database.gameDao.addGame(game: testGameOnlyPlayers); await database.gameDao.addGame(game: testGameOnlyPlayers);
final newPlayers = [testPlayer1, testPlayer2, testPlayer4]; final newPlayers = [testPlayer1, testPlayer2, testPlayer4];
await database.playerDao.addPlayers(players: newPlayers); await database.playerDao.addPlayersAsList(players: newPlayers);
// First, remove all existing players // First, remove all existing players
final existingPlayers = await database.playerGameDao.getPlayersOfGame( final existingPlayers = await database.playerGameDao.getPlayersOfGame(

View File

@@ -56,7 +56,7 @@ void main() {
}); });
test('Adding and fetching multiple players works correctly', () async { test('Adding and fetching multiple players works correctly', () async {
await database.playerDao.addPlayers( await database.playerDao.addPlayersAsList(
players: [testPlayer1, testPlayer2, testPlayer3, testPlayer4], players: [testPlayer1, testPlayer2, testPlayer3, testPlayer4],
); );