From 679e869229d4aebc0f634cc5647f1148572ffcb8 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Wed, 20 May 2026 19:58:59 +0200 Subject: [PATCH] fix: player count calc error --- lib/data/dao/player_dao.dart | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/data/dao/player_dao.dart b/lib/data/dao/player_dao.dart index 71fbe6c..3f13410 100644 --- a/lib/data/dao/player_dao.dart +++ b/lib/data/dao/player_dao.dart @@ -170,22 +170,18 @@ class PlayerDao extends DatabaseAccessor with _$PlayerDaoMixin { .getSingleOrNull() ?? ''; final previousNameCount = (await getNameCount(name: previousPlayerName))!; - print('previousNameCount: $previousNameCount'); // Update name count for the new name - final count = await calculateNameCount(name: name); - print('count: $count'); - + final newNameCount = await calculateNameCount(name: name); + // Updating player name final rowsAffected = await (update(playerTable)..where((p) => p.id.equals(playerId))).write( PlayerTableCompanion(name: Value(name)), ); - - if (count > 0) { - await (update(playerTable)..where((p) => p.name.equals(name))).write( - PlayerTableCompanion(nameCount: Value(count)), - ); - } + // Updating the name count for the new name + await (update(playerTable)..where((p) => p.name.equals(name))).write( + PlayerTableCompanion(nameCount: Value(newNameCount)), + ); if (previousNameCount > 0) { // Get the player with that name and the hightest nameCount, and update their nameCount to previousNameCount