Renamed methods for better distinction
This commit is contained in:
@@ -79,7 +79,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
);
|
||||
|
||||
if (game.players != null) {
|
||||
await db.playerDao.addPlayers(players: game.players!);
|
||||
await db.playerDao.addPlayersAsList(players: game.players!);
|
||||
for (final p in game.players ?? []) {
|
||||
await db.playerGameDao.addPlayerToGame(
|
||||
gameId: game.id,
|
||||
@@ -102,7 +102,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
/// Also adds associated players and groups if they exist.
|
||||
/// If the [games] list is empty, the method returns immediately.
|
||||
/// 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;
|
||||
await db.transaction(() async {
|
||||
// Add all games in batch
|
||||
|
||||
@@ -84,7 +84,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
|
||||
/// Adds multiple groups to the database.
|
||||
/// 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;
|
||||
await db.transaction(() async {
|
||||
// Deduplicate groups by id - keep first occurrence
|
||||
|
||||
@@ -50,7 +50,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
||||
await db.batch(
|
||||
|
||||
@@ -110,9 +110,9 @@ class DataTransferService {
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
await db.playerDao.addPlayers(players: importedPlayers);
|
||||
await db.groupDao.addGroups(groups: importedGroups);
|
||||
await db.gameDao.addGames(games: importedGames);
|
||||
await db.playerDao.addPlayersAsList(players: importedPlayers);
|
||||
await db.groupDao.addGroupsAsList(groups: importedGroups);
|
||||
await db.gameDao.addGamesAsList(games: importedGames);
|
||||
} else {
|
||||
return ImportResult.invalidSchema;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Adding and fetching multiple games works correctly', () async {
|
||||
await database.gameDao.addGames(
|
||||
await database.gameDao.addGamesAsList(
|
||||
games: [testGame1, testGame2, testGameOnlyGroup, testGameOnlyPlayers],
|
||||
);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Adding and fetching multiple groups works correctly', () async {
|
||||
await database.groupDao.addGroups(
|
||||
await database.groupDao.addGroupsAsList(
|
||||
groups: [testGroup1, testGroup2, testGroup3, testGroup4],
|
||||
);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ void main() {
|
||||
await database.gameDao.addGame(game: testGameOnlyPlayers);
|
||||
|
||||
final newPlayers = [testPlayer1, testPlayer2, testPlayer4];
|
||||
await database.playerDao.addPlayers(players: newPlayers);
|
||||
await database.playerDao.addPlayersAsList(players: newPlayers);
|
||||
|
||||
// First, remove all existing players
|
||||
final existingPlayers = await database.playerGameDao.getPlayersOfGame(
|
||||
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Adding and fetching multiple players works correctly', () async {
|
||||
await database.playerDao.addPlayers(
|
||||
await database.playerDao.addPlayersAsList(
|
||||
players: [testPlayer1, testPlayer2, testPlayer3, testPlayer4],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user