Compare commits
14 Commits
80672343b9
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e97f6723a | |||
| 9a0386f22d | |||
| fcf845af4d | |||
| 653b85d28d | |||
| 9a2afbfd3b | |||
| a1398623b0 | |||
| 36fda30f27 | |||
| 1ab869ec26 | |||
| 52b78e44e4 | |||
| e827f4c527 | |||
| 73c85b1ff2 | |||
| c43b7b478c | |||
| c9188c222a | |||
| fcca74cea5 |
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tallee/core/enums.dart';
|
import 'package:tallee/core/enums.dart';
|
||||||
import 'package:tallee/data/models/match.dart';
|
import 'package:tallee/data/models/match.dart';
|
||||||
|
import 'package:tallee/data/models/player.dart';
|
||||||
import 'package:tallee/l10n/generated/app_localizations.dart';
|
import 'package:tallee/l10n/generated/app_localizations.dart';
|
||||||
|
|
||||||
/// Translates a [Ruleset] enum value to its corresponding localized string.
|
/// Translates a [Ruleset] enum value to its corresponding localized string.
|
||||||
@@ -43,3 +44,10 @@ String getExtraPlayerCount(Match match) {
|
|||||||
}
|
}
|
||||||
return ' + ${count.toString()}';
|
return ' + ${count.toString()}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getNameCountText(Player player) {
|
||||||
|
if (player.nameCount >= 1) {
|
||||||
|
return ' #${player.nameCount}';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
final players =
|
final players =
|
||||||
await db.playerMatchDao.getPlayersOfMatch(matchId: row.id) ?? [];
|
await db.playerMatchDao.getPlayersOfMatch(matchId: row.id) ?? [];
|
||||||
|
|
||||||
final scores = await db.scoreDao.getAllMatchScores(matchId: row.id);
|
final scores = await db.scoreEntryDao.getAllMatchScores(
|
||||||
|
matchId: row.id,
|
||||||
|
);
|
||||||
|
|
||||||
final winner = await db.scoreDao.getWinner(matchId: row.id);
|
final winner = await db.scoreEntryDao.getWinner(matchId: row.id);
|
||||||
return Match(
|
return Match(
|
||||||
id: row.id,
|
id: row.id,
|
||||||
name: row.name,
|
name: row.name,
|
||||||
@@ -64,9 +66,9 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
final players =
|
final players =
|
||||||
await db.playerMatchDao.getPlayersOfMatch(matchId: matchId) ?? [];
|
await db.playerMatchDao.getPlayersOfMatch(matchId: matchId) ?? [];
|
||||||
|
|
||||||
final scores = await db.scoreDao.getAllMatchScores(matchId: matchId);
|
final scores = await db.scoreEntryDao.getAllMatchScores(matchId: matchId);
|
||||||
|
|
||||||
final winner = await db.scoreDao.getWinner(matchId: matchId);
|
final winner = await db.scoreEntryDao.getWinner(matchId: matchId);
|
||||||
|
|
||||||
return Match(
|
return Match(
|
||||||
id: result.id,
|
id: result.id,
|
||||||
@@ -109,7 +111,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
|
|
||||||
for (final pid in match.scores.keys) {
|
for (final pid in match.scores.keys) {
|
||||||
final playerScores = match.scores[pid]!;
|
final playerScores = match.scores[pid]!;
|
||||||
await db.scoreDao.addScoresAsList(
|
await db.scoreEntryDao.addScoresAsList(
|
||||||
entrys: playerScores,
|
entrys: playerScores,
|
||||||
playerId: pid,
|
playerId: pid,
|
||||||
matchId: match.id,
|
matchId: match.id,
|
||||||
@@ -117,7 +119,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match.winner != null) {
|
if (match.winner != null) {
|
||||||
await db.scoreDao.setWinner(
|
await db.scoreEntryDao.setWinner(
|
||||||
matchId: match.id,
|
matchId: match.id,
|
||||||
playerId: match.winner!.id,
|
playerId: match.winner!.id,
|
||||||
);
|
);
|
||||||
@@ -298,7 +300,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
final group = await db.groupDao.getGroupById(groupId: groupId);
|
final group = await db.groupDao.getGroupById(groupId: groupId);
|
||||||
final players =
|
final players =
|
||||||
await db.playerMatchDao.getPlayersOfMatch(matchId: row.id) ?? [];
|
await db.playerMatchDao.getPlayersOfMatch(matchId: row.id) ?? [];
|
||||||
final winner = await db.scoreDao.getWinner(matchId: row.id);
|
final winner = await db.scoreEntryDao.getWinner(matchId: row.id);
|
||||||
return Match(
|
return Match(
|
||||||
id: row.id,
|
id: row.id,
|
||||||
name: row.name,
|
name: row.name,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tallee/data/db/database.dart';
|
import 'package:tallee/data/db/database.dart';
|
||||||
import 'package:tallee/data/db/tables/player_table.dart';
|
import 'package:tallee/data/db/tables/player_table.dart';
|
||||||
import 'package:tallee/data/models/player.dart';
|
import 'package:tallee/data/models/player.dart';
|
||||||
@@ -20,6 +21,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
name: row.name,
|
name: row.name,
|
||||||
description: row.description,
|
description: row.description,
|
||||||
createdAt: row.createdAt,
|
createdAt: row.createdAt,
|
||||||
|
nameCount: row.nameCount,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
@@ -34,6 +36,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
name: result.name,
|
name: result.name,
|
||||||
description: result.description,
|
description: result.description,
|
||||||
createdAt: result.createdAt,
|
createdAt: result.createdAt,
|
||||||
|
nameCount: result.nameCount,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,12 +45,15 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
/// the new one.
|
/// the new one.
|
||||||
Future<bool> addPlayer({required Player player}) async {
|
Future<bool> addPlayer({required Player player}) async {
|
||||||
if (!await playerExists(playerId: player.id)) {
|
if (!await playerExists(playerId: player.id)) {
|
||||||
|
final int nameCount = await calculateNameCount(name: player.name);
|
||||||
|
|
||||||
await into(playerTable).insert(
|
await into(playerTable).insert(
|
||||||
PlayerTableCompanion.insert(
|
PlayerTableCompanion.insert(
|
||||||
id: player.id,
|
id: player.id,
|
||||||
name: player.name,
|
name: player.name,
|
||||||
description: player.description,
|
description: player.description,
|
||||||
createdAt: player.createdAt,
|
createdAt: player.createdAt,
|
||||||
|
nameCount: Value(nameCount),
|
||||||
),
|
),
|
||||||
mode: InsertMode.insertOrReplace,
|
mode: InsertMode.insertOrReplace,
|
||||||
);
|
);
|
||||||
@@ -62,20 +68,67 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
Future<bool> addPlayersAsList({required List<Player> players}) async {
|
Future<bool> addPlayersAsList({required List<Player> players}) async {
|
||||||
if (players.isEmpty) return false;
|
if (players.isEmpty) return false;
|
||||||
|
|
||||||
|
// Filter out players that already exist
|
||||||
|
final newPlayers = <Player>[];
|
||||||
|
for (final player in players) {
|
||||||
|
if (!await playerExists(playerId: player.id)) {
|
||||||
|
newPlayers.add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPlayers.isEmpty) return false;
|
||||||
|
|
||||||
|
// Group players by name
|
||||||
|
final nameGroups = <String, List<Player>>{};
|
||||||
|
for (final player in newPlayers) {
|
||||||
|
nameGroups.putIfAbsent(player.name, () => []).add(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
final playersToInsert = <PlayerTableCompanion>[];
|
||||||
|
|
||||||
|
// Process each group of players with the same name
|
||||||
|
for (final entry in nameGroups.entries) {
|
||||||
|
final name = entry.key;
|
||||||
|
final playersWithName = entry.value;
|
||||||
|
|
||||||
|
// Get the current nameCount
|
||||||
|
var nameCount = await calculateNameCount(name: name);
|
||||||
|
|
||||||
|
// One player with the same name
|
||||||
|
if (playersWithName.length == 1) {
|
||||||
|
final player = playersWithName[0];
|
||||||
|
playersToInsert.add(
|
||||||
|
PlayerTableCompanion.insert(
|
||||||
|
id: player.id,
|
||||||
|
name: player.name,
|
||||||
|
description: player.description,
|
||||||
|
createdAt: player.createdAt,
|
||||||
|
nameCount: Value(nameCount),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (nameCount == 0) nameCount++;
|
||||||
|
// Multiple players with the same name
|
||||||
|
for (var i = 0; i < playersWithName.length; i++) {
|
||||||
|
final player = playersWithName[i];
|
||||||
|
playersToInsert.add(
|
||||||
|
PlayerTableCompanion.insert(
|
||||||
|
id: player.id,
|
||||||
|
name: player.name,
|
||||||
|
description: player.description,
|
||||||
|
createdAt: player.createdAt,
|
||||||
|
nameCount: Value(nameCount + i),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await db.batch(
|
await db.batch(
|
||||||
(b) => b.insertAll(
|
(b) => b.insertAll(
|
||||||
playerTable,
|
playerTable,
|
||||||
players
|
playersToInsert,
|
||||||
.map(
|
mode: InsertMode.insertOrReplace,
|
||||||
(player) => PlayerTableCompanion.insert(
|
|
||||||
id: player.id,
|
|
||||||
name: player.name,
|
|
||||||
description: player.description,
|
|
||||||
createdAt: player.createdAt,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
mode: InsertMode.insertOrIgnore,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -90,7 +143,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a player with the given [id] exists in the database.
|
/// Checks if a player with the given [playerId] exists in the database.
|
||||||
/// Returns `true` if the player exists, `false` otherwise.
|
/// Returns `true` if the player exists, `false` otherwise.
|
||||||
Future<bool> playerExists({required String playerId}) async {
|
Future<bool> playerExists({required String playerId}) async {
|
||||||
final query = select(playerTable)..where((p) => p.id.equals(playerId));
|
final query = select(playerTable)..where((p) => p.id.equals(playerId));
|
||||||
@@ -103,9 +156,38 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
required String playerId,
|
required String playerId,
|
||||||
required String newName,
|
required String newName,
|
||||||
}) async {
|
}) async {
|
||||||
|
// Get previous name and name count for the player before updating
|
||||||
|
final previousPlayerName =
|
||||||
|
await (select(playerTable)..where((p) => p.id.equals(playerId)))
|
||||||
|
.map((row) => row.name)
|
||||||
|
.getSingleOrNull() ??
|
||||||
|
'';
|
||||||
|
final previousNameCount = await getNameCount(name: previousPlayerName);
|
||||||
|
|
||||||
await (update(playerTable)..where((p) => p.id.equals(playerId))).write(
|
await (update(playerTable)..where((p) => p.id.equals(playerId))).write(
|
||||||
PlayerTableCompanion(name: Value(newName)),
|
PlayerTableCompanion(name: Value(newName)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Update name count for the new name
|
||||||
|
final count = await calculateNameCount(name: newName);
|
||||||
|
if (count > 0) {
|
||||||
|
await (update(playerTable)..where((p) => p.name.equals(newName))).write(
|
||||||
|
PlayerTableCompanion(nameCount: Value(count)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousNameCount > 0) {
|
||||||
|
// Get the player with that name and the hightest nameCount, and update their nameCount to previousNameCount
|
||||||
|
final player = await getPlayerWithHighestNameCount(
|
||||||
|
name: previousPlayerName,
|
||||||
|
);
|
||||||
|
if (player != null) {
|
||||||
|
await updateNameCount(
|
||||||
|
playerId: player.id,
|
||||||
|
nameCount: previousNameCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the total count of players in the database.
|
/// Retrieves the total count of players in the database.
|
||||||
@@ -117,6 +199,76 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
return count ?? 0;
|
return count ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the count of players with the given [name].
|
||||||
|
Future<int> getNameCount({required String name}) async {
|
||||||
|
final query = select(playerTable)..where((p) => p.name.equals(name));
|
||||||
|
final result = await query.get();
|
||||||
|
return result.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates the nameCount for the player with the given [playerId] to [nameCount].
|
||||||
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
|
Future<bool> updateNameCount({
|
||||||
|
required String playerId,
|
||||||
|
required int nameCount,
|
||||||
|
}) async {
|
||||||
|
final query = update(playerTable)..where((p) => p.id.equals(playerId));
|
||||||
|
final rowsAffected = await query.write(
|
||||||
|
PlayerTableCompanion(nameCount: Value(nameCount)),
|
||||||
|
);
|
||||||
|
return rowsAffected > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
Future<Player?> getPlayerWithHighestNameCount({required String name}) async {
|
||||||
|
final query = select(playerTable)
|
||||||
|
..where((p) => p.name.equals(name))
|
||||||
|
..orderBy([(p) => OrderingTerm.desc(p.nameCount)])
|
||||||
|
..limit(1);
|
||||||
|
final result = await query.getSingleOrNull();
|
||||||
|
if (result != null) {
|
||||||
|
return Player(
|
||||||
|
id: result.id,
|
||||||
|
name: result.name,
|
||||||
|
description: result.description,
|
||||||
|
createdAt: result.createdAt,
|
||||||
|
nameCount: result.nameCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
Future<int> calculateNameCount({required String name}) async {
|
||||||
|
final count = await getNameCount(name: name);
|
||||||
|
final int nameCount;
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
// If one other player exists with the same name, initialize the nameCount
|
||||||
|
await initializeNameCount(name: name);
|
||||||
|
// And for the new player, set nameCount to 2
|
||||||
|
nameCount = 2;
|
||||||
|
} else if (count > 1) {
|
||||||
|
// If more than one player exists with the same name, just increment
|
||||||
|
// the nameCount for the new player
|
||||||
|
nameCount = count + 1;
|
||||||
|
} else {
|
||||||
|
// If no other players exist with the same name, set nameCount to 0
|
||||||
|
nameCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
Future<bool> initializeNameCount({required String name}) async {
|
||||||
|
final rowsAffected =
|
||||||
|
await (update(playerTable)..where((p) => p.name.equals(name))).write(
|
||||||
|
const PlayerTableCompanion(nameCount: Value(1)),
|
||||||
|
);
|
||||||
|
return rowsAffected > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// Deletes all players from the database.
|
/// Deletes all players from the database.
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> deleteAllPlayers() async {
|
Future<bool> deleteAllPlayers() async {
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import 'package:tallee/data/db/tables/score_entry_table.dart';
|
|||||||
import 'package:tallee/data/models/player.dart';
|
import 'package:tallee/data/models/player.dart';
|
||||||
import 'package:tallee/data/models/score_entry.dart';
|
import 'package:tallee/data/models/score_entry.dart';
|
||||||
|
|
||||||
part 'score_dao.g.dart';
|
part 'score_entry_dao.g.dart';
|
||||||
|
|
||||||
@DriftAccessor(tables: [ScoreEntryTable])
|
@DriftAccessor(tables: [ScoreEntryTable])
|
||||||
class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
|
class ScoreEntryDao extends DatabaseAccessor<AppDatabase>
|
||||||
ScoreDao(super.db);
|
with _$ScoreEntryDaoMixin {
|
||||||
|
ScoreEntryDao(super.db);
|
||||||
|
|
||||||
/// Adds a score entry to the database.
|
/// Adds a score entry to the database.
|
||||||
Future<void> addScore({
|
Future<void> addScore({
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
part of 'score_dao.dart';
|
part of 'score_entry_dao.dart';
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
mixin _$ScoreDaoMixin on DatabaseAccessor<AppDatabase> {
|
mixin _$ScoreEntryDaoMixin on DatabaseAccessor<AppDatabase> {
|
||||||
$PlayerTableTable get playerTable => attachedDatabase.playerTable;
|
$PlayerTableTable get playerTable => attachedDatabase.playerTable;
|
||||||
$GameTableTable get gameTable => attachedDatabase.gameTable;
|
$GameTableTable get gameTable => attachedDatabase.gameTable;
|
||||||
$GroupTableTable get groupTable => attachedDatabase.groupTable;
|
$GroupTableTable get groupTable => attachedDatabase.groupTable;
|
||||||
$MatchTableTable get matchTable => attachedDatabase.matchTable;
|
$MatchTableTable get matchTable => attachedDatabase.matchTable;
|
||||||
$ScoreEntryTableTable get scoreEntryTable => attachedDatabase.scoreEntryTable;
|
$ScoreEntryTableTable get scoreEntryTable => attachedDatabase.scoreEntryTable;
|
||||||
ScoreDaoManager get managers => ScoreDaoManager(this);
|
ScoreEntryDaoManager get managers => ScoreEntryDaoManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScoreDaoManager {
|
class ScoreEntryDaoManager {
|
||||||
final _$ScoreDaoMixin _db;
|
final _$ScoreEntryDaoMixin _db;
|
||||||
ScoreDaoManager(this._db);
|
ScoreEntryDaoManager(this._db);
|
||||||
$$PlayerTableTableTableManager get playerTable =>
|
$$PlayerTableTableTableManager get playerTable =>
|
||||||
$$PlayerTableTableTableManager(_db.attachedDatabase, _db.playerTable);
|
$$PlayerTableTableTableManager(_db.attachedDatabase, _db.playerTable);
|
||||||
$$GameTableTableTableManager get gameTable =>
|
$$GameTableTableTableManager get gameTable =>
|
||||||
@@ -7,7 +7,7 @@ import 'package:tallee/data/dao/match_dao.dart';
|
|||||||
import 'package:tallee/data/dao/player_dao.dart';
|
import 'package:tallee/data/dao/player_dao.dart';
|
||||||
import 'package:tallee/data/dao/player_group_dao.dart';
|
import 'package:tallee/data/dao/player_group_dao.dart';
|
||||||
import 'package:tallee/data/dao/player_match_dao.dart';
|
import 'package:tallee/data/dao/player_match_dao.dart';
|
||||||
import 'package:tallee/data/dao/score_dao.dart';
|
import 'package:tallee/data/dao/score_entry_dao.dart';
|
||||||
import 'package:tallee/data/dao/team_dao.dart';
|
import 'package:tallee/data/dao/team_dao.dart';
|
||||||
import 'package:tallee/data/db/tables/game_table.dart';
|
import 'package:tallee/data/db/tables/game_table.dart';
|
||||||
import 'package:tallee/data/db/tables/group_table.dart';
|
import 'package:tallee/data/db/tables/group_table.dart';
|
||||||
@@ -38,7 +38,7 @@ part 'database.g.dart';
|
|||||||
PlayerGroupDao,
|
PlayerGroupDao,
|
||||||
PlayerMatchDao,
|
PlayerMatchDao,
|
||||||
GameDao,
|
GameDao,
|
||||||
ScoreDao,
|
ScoreEntryDao,
|
||||||
TeamDao,
|
TeamDao,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
type: DriftSqlType.string,
|
type: DriftSqlType.string,
|
||||||
requiredDuringInsert: true,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
|
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
||||||
|
'createdAt',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
||||||
|
'created_at',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: DriftSqlType.dateTime,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
);
|
||||||
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||||
@@ -27,6 +38,18 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
type: DriftSqlType.string,
|
type: DriftSqlType.string,
|
||||||
requiredDuringInsert: true,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
|
static const VerificationMeta _nameCountMeta = const VerificationMeta(
|
||||||
|
'nameCount',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final GeneratedColumn<int> nameCount = GeneratedColumn<int>(
|
||||||
|
'name_count',
|
||||||
|
aliasedName,
|
||||||
|
false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: const Constant(0),
|
||||||
|
);
|
||||||
static const VerificationMeta _descriptionMeta = const VerificationMeta(
|
static const VerificationMeta _descriptionMeta = const VerificationMeta(
|
||||||
'description',
|
'description',
|
||||||
);
|
);
|
||||||
@@ -38,19 +61,14 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
type: DriftSqlType.string,
|
type: DriftSqlType.string,
|
||||||
requiredDuringInsert: true,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
|
||||||
'createdAt',
|
|
||||||
);
|
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
List<GeneratedColumn> get $columns => [
|
||||||
'created_at',
|
id,
|
||||||
aliasedName,
|
createdAt,
|
||||||
false,
|
name,
|
||||||
type: DriftSqlType.dateTime,
|
nameCount,
|
||||||
requiredDuringInsert: true,
|
description,
|
||||||
);
|
];
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name, description, createdAt];
|
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@override
|
@override
|
||||||
@@ -68,6 +86,14 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_idMeta);
|
context.missing(_idMeta);
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('created_at')) {
|
||||||
|
context.handle(
|
||||||
|
_createdAtMeta,
|
||||||
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta),
|
||||||
|
);
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_createdAtMeta);
|
||||||
|
}
|
||||||
if (data.containsKey('name')) {
|
if (data.containsKey('name')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
_nameMeta,
|
_nameMeta,
|
||||||
@@ -76,6 +102,12 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_nameMeta);
|
context.missing(_nameMeta);
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('name_count')) {
|
||||||
|
context.handle(
|
||||||
|
_nameCountMeta,
|
||||||
|
nameCount.isAcceptableOrUnknown(data['name_count']!, _nameCountMeta),
|
||||||
|
);
|
||||||
|
}
|
||||||
if (data.containsKey('description')) {
|
if (data.containsKey('description')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
_descriptionMeta,
|
_descriptionMeta,
|
||||||
@@ -87,14 +119,6 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_descriptionMeta);
|
context.missing(_descriptionMeta);
|
||||||
}
|
}
|
||||||
if (data.containsKey('created_at')) {
|
|
||||||
context.handle(
|
|
||||||
_createdAtMeta,
|
|
||||||
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta),
|
|
||||||
);
|
|
||||||
} else if (isInserting) {
|
|
||||||
context.missing(_createdAtMeta);
|
|
||||||
}
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,18 +132,22 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}id'],
|
data['${effectivePrefix}id'],
|
||||||
)!,
|
)!,
|
||||||
|
createdAt: attachedDatabase.typeMapping.read(
|
||||||
|
DriftSqlType.dateTime,
|
||||||
|
data['${effectivePrefix}created_at'],
|
||||||
|
)!,
|
||||||
name: attachedDatabase.typeMapping.read(
|
name: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}name'],
|
data['${effectivePrefix}name'],
|
||||||
)!,
|
)!,
|
||||||
|
nameCount: attachedDatabase.typeMapping.read(
|
||||||
|
DriftSqlType.int,
|
||||||
|
data['${effectivePrefix}name_count'],
|
||||||
|
)!,
|
||||||
description: attachedDatabase.typeMapping.read(
|
description: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}description'],
|
data['${effectivePrefix}description'],
|
||||||
)!,
|
)!,
|
||||||
createdAt: attachedDatabase.typeMapping.read(
|
|
||||||
DriftSqlType.dateTime,
|
|
||||||
data['${effectivePrefix}created_at'],
|
|
||||||
)!,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,31 +159,35 @@ class $PlayerTableTable extends PlayerTable
|
|||||||
|
|
||||||
class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
|
||||||
final String description;
|
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
|
final String name;
|
||||||
|
final int nameCount;
|
||||||
|
final String description;
|
||||||
const PlayerTableData({
|
const PlayerTableData({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
|
||||||
required this.description,
|
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
|
required this.name,
|
||||||
|
required this.nameCount,
|
||||||
|
required this.description,
|
||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, Expression>{};
|
final map = <String, Expression>{};
|
||||||
map['id'] = Variable<String>(id);
|
map['id'] = Variable<String>(id);
|
||||||
map['name'] = Variable<String>(name);
|
|
||||||
map['description'] = Variable<String>(description);
|
|
||||||
map['created_at'] = Variable<DateTime>(createdAt);
|
map['created_at'] = Variable<DateTime>(createdAt);
|
||||||
|
map['name'] = Variable<String>(name);
|
||||||
|
map['name_count'] = Variable<int>(nameCount);
|
||||||
|
map['description'] = Variable<String>(description);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerTableCompanion toCompanion(bool nullToAbsent) {
|
PlayerTableCompanion toCompanion(bool nullToAbsent) {
|
||||||
return PlayerTableCompanion(
|
return PlayerTableCompanion(
|
||||||
id: Value(id),
|
id: Value(id),
|
||||||
name: Value(name),
|
|
||||||
description: Value(description),
|
|
||||||
createdAt: Value(createdAt),
|
createdAt: Value(createdAt),
|
||||||
|
name: Value(name),
|
||||||
|
nameCount: Value(nameCount),
|
||||||
|
description: Value(description),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,9 +198,10 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
|||||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
return PlayerTableData(
|
return PlayerTableData(
|
||||||
id: serializer.fromJson<String>(json['id']),
|
id: serializer.fromJson<String>(json['id']),
|
||||||
name: serializer.fromJson<String>(json['name']),
|
|
||||||
description: serializer.fromJson<String>(json['description']),
|
|
||||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||||
|
name: serializer.fromJson<String>(json['name']),
|
||||||
|
nameCount: serializer.fromJson<int>(json['nameCount']),
|
||||||
|
description: serializer.fromJson<String>(json['description']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@@ -176,31 +209,35 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
|||||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
'id': serializer.toJson<String>(id),
|
'id': serializer.toJson<String>(id),
|
||||||
'name': serializer.toJson<String>(name),
|
|
||||||
'description': serializer.toJson<String>(description),
|
|
||||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||||
|
'name': serializer.toJson<String>(name),
|
||||||
|
'nameCount': serializer.toJson<int>(nameCount),
|
||||||
|
'description': serializer.toJson<String>(description),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerTableData copyWith({
|
PlayerTableData copyWith({
|
||||||
String? id,
|
String? id,
|
||||||
String? name,
|
|
||||||
String? description,
|
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
|
String? name,
|
||||||
|
int? nameCount,
|
||||||
|
String? description,
|
||||||
}) => PlayerTableData(
|
}) => PlayerTableData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
|
||||||
description: description ?? this.description,
|
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
|
name: name ?? this.name,
|
||||||
|
nameCount: nameCount ?? this.nameCount,
|
||||||
|
description: description ?? this.description,
|
||||||
);
|
);
|
||||||
PlayerTableData copyWithCompanion(PlayerTableCompanion data) {
|
PlayerTableData copyWithCompanion(PlayerTableCompanion data) {
|
||||||
return PlayerTableData(
|
return PlayerTableData(
|
||||||
id: data.id.present ? data.id.value : this.id,
|
id: data.id.present ? data.id.value : this.id,
|
||||||
|
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
||||||
name: data.name.present ? data.name.value : this.name,
|
name: data.name.present ? data.name.value : this.name,
|
||||||
|
nameCount: data.nameCount.present ? data.nameCount.value : this.nameCount,
|
||||||
description: data.description.present
|
description: data.description.present
|
||||||
? data.description.value
|
? data.description.value
|
||||||
: this.description,
|
: this.description,
|
||||||
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,76 +245,85 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('PlayerTableData(')
|
return (StringBuffer('PlayerTableData(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
|
..write('createdAt: $createdAt, ')
|
||||||
..write('name: $name, ')
|
..write('name: $name, ')
|
||||||
..write('description: $description, ')
|
..write('nameCount: $nameCount, ')
|
||||||
..write('createdAt: $createdAt')
|
..write('description: $description')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(id, name, description, createdAt);
|
int get hashCode => Object.hash(id, createdAt, name, nameCount, description);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
(other is PlayerTableData &&
|
(other is PlayerTableData &&
|
||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
|
other.createdAt == this.createdAt &&
|
||||||
other.name == this.name &&
|
other.name == this.name &&
|
||||||
other.description == this.description &&
|
other.nameCount == this.nameCount &&
|
||||||
other.createdAt == this.createdAt);
|
other.description == this.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
||||||
final Value<String> id;
|
final Value<String> id;
|
||||||
final Value<String> name;
|
|
||||||
final Value<String> description;
|
|
||||||
final Value<DateTime> createdAt;
|
final Value<DateTime> createdAt;
|
||||||
|
final Value<String> name;
|
||||||
|
final Value<int> nameCount;
|
||||||
|
final Value<String> description;
|
||||||
final Value<int> rowid;
|
final Value<int> rowid;
|
||||||
const PlayerTableCompanion({
|
const PlayerTableCompanion({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
this.name = const Value.absent(),
|
|
||||||
this.description = const Value.absent(),
|
|
||||||
this.createdAt = const Value.absent(),
|
this.createdAt = const Value.absent(),
|
||||||
|
this.name = const Value.absent(),
|
||||||
|
this.nameCount = const Value.absent(),
|
||||||
|
this.description = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
});
|
});
|
||||||
PlayerTableCompanion.insert({
|
PlayerTableCompanion.insert({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
|
||||||
required String description,
|
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
|
required String name,
|
||||||
|
this.nameCount = const Value.absent(),
|
||||||
|
required String description,
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
}) : id = Value(id),
|
}) : id = Value(id),
|
||||||
|
createdAt = Value(createdAt),
|
||||||
name = Value(name),
|
name = Value(name),
|
||||||
description = Value(description),
|
description = Value(description);
|
||||||
createdAt = Value(createdAt);
|
|
||||||
static Insertable<PlayerTableData> custom({
|
static Insertable<PlayerTableData> custom({
|
||||||
Expression<String>? id,
|
Expression<String>? id,
|
||||||
Expression<String>? name,
|
|
||||||
Expression<String>? description,
|
|
||||||
Expression<DateTime>? createdAt,
|
Expression<DateTime>? createdAt,
|
||||||
|
Expression<String>? name,
|
||||||
|
Expression<int>? nameCount,
|
||||||
|
Expression<String>? description,
|
||||||
Expression<int>? rowid,
|
Expression<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
if (name != null) 'name': name,
|
|
||||||
if (description != null) 'description': description,
|
|
||||||
if (createdAt != null) 'created_at': createdAt,
|
if (createdAt != null) 'created_at': createdAt,
|
||||||
|
if (name != null) 'name': name,
|
||||||
|
if (nameCount != null) 'name_count': nameCount,
|
||||||
|
if (description != null) 'description': description,
|
||||||
if (rowid != null) 'rowid': rowid,
|
if (rowid != null) 'rowid': rowid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerTableCompanion copyWith({
|
PlayerTableCompanion copyWith({
|
||||||
Value<String>? id,
|
Value<String>? id,
|
||||||
Value<String>? name,
|
|
||||||
Value<String>? description,
|
|
||||||
Value<DateTime>? createdAt,
|
Value<DateTime>? createdAt,
|
||||||
|
Value<String>? name,
|
||||||
|
Value<int>? nameCount,
|
||||||
|
Value<String>? description,
|
||||||
Value<int>? rowid,
|
Value<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return PlayerTableCompanion(
|
return PlayerTableCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
|
||||||
description: description ?? this.description,
|
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
|
name: name ?? this.name,
|
||||||
|
nameCount: nameCount ?? this.nameCount,
|
||||||
|
description: description ?? this.description,
|
||||||
rowid: rowid ?? this.rowid,
|
rowid: rowid ?? this.rowid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -288,15 +334,18 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
|||||||
if (id.present) {
|
if (id.present) {
|
||||||
map['id'] = Variable<String>(id.value);
|
map['id'] = Variable<String>(id.value);
|
||||||
}
|
}
|
||||||
|
if (createdAt.present) {
|
||||||
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
||||||
|
}
|
||||||
if (name.present) {
|
if (name.present) {
|
||||||
map['name'] = Variable<String>(name.value);
|
map['name'] = Variable<String>(name.value);
|
||||||
}
|
}
|
||||||
|
if (nameCount.present) {
|
||||||
|
map['name_count'] = Variable<int>(nameCount.value);
|
||||||
|
}
|
||||||
if (description.present) {
|
if (description.present) {
|
||||||
map['description'] = Variable<String>(description.value);
|
map['description'] = Variable<String>(description.value);
|
||||||
}
|
}
|
||||||
if (createdAt.present) {
|
|
||||||
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
||||||
}
|
|
||||||
if (rowid.present) {
|
if (rowid.present) {
|
||||||
map['rowid'] = Variable<int>(rowid.value);
|
map['rowid'] = Variable<int>(rowid.value);
|
||||||
}
|
}
|
||||||
@@ -307,9 +356,10 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('PlayerTableCompanion(')
|
return (StringBuffer('PlayerTableCompanion(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('name: $name, ')
|
|
||||||
..write('description: $description, ')
|
|
||||||
..write('createdAt: $createdAt, ')
|
..write('createdAt: $createdAt, ')
|
||||||
|
..write('name: $name, ')
|
||||||
|
..write('nameCount: $nameCount, ')
|
||||||
|
..write('description: $description, ')
|
||||||
..write('rowid: $rowid')
|
..write('rowid: $rowid')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
@@ -2710,7 +2760,7 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
|||||||
this as AppDatabase,
|
this as AppDatabase,
|
||||||
);
|
);
|
||||||
late final GameDao gameDao = GameDao(this as AppDatabase);
|
late final GameDao gameDao = GameDao(this as AppDatabase);
|
||||||
late final ScoreDao scoreDao = ScoreDao(this as AppDatabase);
|
late final ScoreEntryDao scoreEntryDao = ScoreEntryDao(this as AppDatabase);
|
||||||
late final TeamDao teamDao = TeamDao(this as AppDatabase);
|
late final TeamDao teamDao = TeamDao(this as AppDatabase);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||||
@@ -2790,17 +2840,19 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
|||||||
typedef $$PlayerTableTableCreateCompanionBuilder =
|
typedef $$PlayerTableTableCreateCompanionBuilder =
|
||||||
PlayerTableCompanion Function({
|
PlayerTableCompanion Function({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
|
||||||
required String description,
|
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
|
required String name,
|
||||||
|
Value<int> nameCount,
|
||||||
|
required String description,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
typedef $$PlayerTableTableUpdateCompanionBuilder =
|
typedef $$PlayerTableTableUpdateCompanionBuilder =
|
||||||
PlayerTableCompanion Function({
|
PlayerTableCompanion Function({
|
||||||
Value<String> id,
|
Value<String> id,
|
||||||
Value<String> name,
|
|
||||||
Value<String> description,
|
|
||||||
Value<DateTime> createdAt,
|
Value<DateTime> createdAt,
|
||||||
|
Value<String> name,
|
||||||
|
Value<int> nameCount,
|
||||||
|
Value<String> description,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2892,18 +2944,23 @@ class $$PlayerTableTableFilterComposer
|
|||||||
builder: (column) => ColumnFilters(column),
|
builder: (column) => ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ColumnFilters<DateTime> get createdAt => $composableBuilder(
|
||||||
|
column: $table.createdAt,
|
||||||
|
builder: (column) => ColumnFilters(column),
|
||||||
|
);
|
||||||
|
|
||||||
ColumnFilters<String> get name => $composableBuilder(
|
ColumnFilters<String> get name => $composableBuilder(
|
||||||
column: $table.name,
|
column: $table.name,
|
||||||
builder: (column) => ColumnFilters(column),
|
builder: (column) => ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
ColumnFilters<String> get description => $composableBuilder(
|
ColumnFilters<int> get nameCount => $composableBuilder(
|
||||||
column: $table.description,
|
column: $table.nameCount,
|
||||||
builder: (column) => ColumnFilters(column),
|
builder: (column) => ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
ColumnFilters<DateTime> get createdAt => $composableBuilder(
|
ColumnFilters<String> get description => $composableBuilder(
|
||||||
column: $table.createdAt,
|
column: $table.description,
|
||||||
builder: (column) => ColumnFilters(column),
|
builder: (column) => ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2997,18 +3054,23 @@ class $$PlayerTableTableOrderingComposer
|
|||||||
builder: (column) => ColumnOrderings(column),
|
builder: (column) => ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ColumnOrderings<DateTime> get createdAt => $composableBuilder(
|
||||||
|
column: $table.createdAt,
|
||||||
|
builder: (column) => ColumnOrderings(column),
|
||||||
|
);
|
||||||
|
|
||||||
ColumnOrderings<String> get name => $composableBuilder(
|
ColumnOrderings<String> get name => $composableBuilder(
|
||||||
column: $table.name,
|
column: $table.name,
|
||||||
builder: (column) => ColumnOrderings(column),
|
builder: (column) => ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
ColumnOrderings<String> get description => $composableBuilder(
|
ColumnOrderings<int> get nameCount => $composableBuilder(
|
||||||
column: $table.description,
|
column: $table.nameCount,
|
||||||
builder: (column) => ColumnOrderings(column),
|
builder: (column) => ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
ColumnOrderings<DateTime> get createdAt => $composableBuilder(
|
ColumnOrderings<String> get description => $composableBuilder(
|
||||||
column: $table.createdAt,
|
column: $table.description,
|
||||||
builder: (column) => ColumnOrderings(column),
|
builder: (column) => ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3025,17 +3087,20 @@ class $$PlayerTableTableAnnotationComposer
|
|||||||
GeneratedColumn<String> get id =>
|
GeneratedColumn<String> get id =>
|
||||||
$composableBuilder(column: $table.id, builder: (column) => column);
|
$composableBuilder(column: $table.id, builder: (column) => column);
|
||||||
|
|
||||||
|
GeneratedColumn<DateTime> get createdAt =>
|
||||||
|
$composableBuilder(column: $table.createdAt, builder: (column) => column);
|
||||||
|
|
||||||
GeneratedColumn<String> get name =>
|
GeneratedColumn<String> get name =>
|
||||||
$composableBuilder(column: $table.name, builder: (column) => column);
|
$composableBuilder(column: $table.name, builder: (column) => column);
|
||||||
|
|
||||||
|
GeneratedColumn<int> get nameCount =>
|
||||||
|
$composableBuilder(column: $table.nameCount, builder: (column) => column);
|
||||||
|
|
||||||
GeneratedColumn<String> get description => $composableBuilder(
|
GeneratedColumn<String> get description => $composableBuilder(
|
||||||
column: $table.description,
|
column: $table.description,
|
||||||
builder: (column) => column,
|
builder: (column) => column,
|
||||||
);
|
);
|
||||||
|
|
||||||
GeneratedColumn<DateTime> get createdAt =>
|
|
||||||
$composableBuilder(column: $table.createdAt, builder: (column) => column);
|
|
||||||
|
|
||||||
Expression<T> playerGroupTableRefs<T extends Object>(
|
Expression<T> playerGroupTableRefs<T extends Object>(
|
||||||
Expression<T> Function($$PlayerGroupTableTableAnnotationComposer a) f,
|
Expression<T> Function($$PlayerGroupTableTableAnnotationComposer a) f,
|
||||||
) {
|
) {
|
||||||
@@ -3145,29 +3210,33 @@ class $$PlayerTableTableTableManager
|
|||||||
updateCompanionCallback:
|
updateCompanionCallback:
|
||||||
({
|
({
|
||||||
Value<String> id = const Value.absent(),
|
Value<String> id = const Value.absent(),
|
||||||
Value<String> name = const Value.absent(),
|
|
||||||
Value<String> description = const Value.absent(),
|
|
||||||
Value<DateTime> createdAt = const Value.absent(),
|
Value<DateTime> createdAt = const Value.absent(),
|
||||||
|
Value<String> name = const Value.absent(),
|
||||||
|
Value<int> nameCount = const Value.absent(),
|
||||||
|
Value<String> description = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) => PlayerTableCompanion(
|
}) => PlayerTableCompanion(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
|
||||||
description: description,
|
|
||||||
createdAt: createdAt,
|
createdAt: createdAt,
|
||||||
|
name: name,
|
||||||
|
nameCount: nameCount,
|
||||||
|
description: description,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
createCompanionCallback:
|
createCompanionCallback:
|
||||||
({
|
({
|
||||||
required String id,
|
required String id,
|
||||||
required String name,
|
|
||||||
required String description,
|
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
|
required String name,
|
||||||
|
Value<int> nameCount = const Value.absent(),
|
||||||
|
required String description,
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) => PlayerTableCompanion.insert(
|
}) => PlayerTableCompanion.insert(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
|
||||||
description: description,
|
|
||||||
createdAt: createdAt,
|
createdAt: createdAt,
|
||||||
|
name: name,
|
||||||
|
nameCount: nameCount,
|
||||||
|
description: description,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
withReferenceMapper: (p0) => p0
|
withReferenceMapper: (p0) => p0
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import 'package:drift/drift.dart';
|
|||||||
|
|
||||||
class PlayerTable extends Table {
|
class PlayerTable extends Table {
|
||||||
TextColumn get id => text()();
|
TextColumn get id => text()();
|
||||||
TextColumn get name => text()();
|
|
||||||
TextColumn get description => text()();
|
|
||||||
DateTimeColumn get createdAt => dateTime()();
|
DateTimeColumn get createdAt => dateTime()();
|
||||||
|
TextColumn get name => text()();
|
||||||
|
IntColumn get nameCount => integer().withDefault(const Constant(0))();
|
||||||
|
TextColumn get description => text()();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column<Object>> get primaryKey => {id};
|
Set<Column<Object>> get primaryKey => {id};
|
||||||
|
|||||||
@@ -24,16 +24,17 @@ class Group {
|
|||||||
return 'Group{id: $id, name: $name, description: $description, members: $members}';
|
return 'Group{id: $id, name: $name, description: $description, members: $members}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Group instance from a JSON object (memberIds format).
|
/// Creates a Group instance from a JSON object where the related [Player]
|
||||||
/// Player objects are reconstructed from memberIds by the DataTransferService.
|
/// objects are represented by their IDs.
|
||||||
Group.fromJson(Map<String, dynamic> json)
|
Group.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
createdAt = DateTime.parse(json['createdAt']),
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
name = json['name'],
|
name = json['name'],
|
||||||
description = json['description'],
|
description = json['description'],
|
||||||
members = []; // Populated during import via DataTransferService
|
members = [];
|
||||||
|
|
||||||
/// Converts the Group instance to a JSON object using normalized format (memberIds only).
|
/// Converts the Group instance to a JSON object. Related [Player] objects are
|
||||||
|
/// represented by their IDs.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'createdAt': createdAt.toIso8601String(),
|
'createdAt': createdAt.toIso8601String(),
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ class Match {
|
|||||||
return 'Match{id: $id, createdAt: $createdAt, endedAt: $endedAt, name: $name, game: $game, group: $group, players: $players, notes: $notes, scores: $scores, winner: $winner}';
|
return 'Match{id: $id, createdAt: $createdAt, endedAt: $endedAt, name: $name, game: $game, group: $group, players: $players, notes: $notes, scores: $scores, winner: $winner}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Match instance from a JSON object (ID references format).
|
/// Creates a Match instance from a JSON object where related objects are
|
||||||
/// Related objects are reconstructed from IDs by the DataTransferService.
|
/// represented by their IDs. Therefore, the game, group, and players are not
|
||||||
|
/// fully constructed here.
|
||||||
Match.fromJson(Map<String, dynamic> json)
|
Match.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
createdAt = DateTime.parse(json['createdAt']),
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
@@ -53,13 +54,15 @@ class Match {
|
|||||||
description: '',
|
description: '',
|
||||||
color: GameColor.blue,
|
color: GameColor.blue,
|
||||||
icon: '',
|
icon: '',
|
||||||
), // Populated during import via DataTransferService
|
),
|
||||||
group = null, // Populated during import via DataTransferService
|
group = null,
|
||||||
players = [], // Populated during import via DataTransferService
|
players = [],
|
||||||
scores = json['scores'],
|
scores = json['scores'],
|
||||||
notes = json['notes'] ?? '';
|
notes = json['notes'] ?? '';
|
||||||
|
|
||||||
/// Converts the Match instance to a JSON object using normalized format (ID references only).
|
/// Converts the Match instance to a JSON object. Related objects are
|
||||||
|
/// represented by their IDs, so the game, group, and players are not fully
|
||||||
|
/// serialized here.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'createdAt': createdAt.toIso8601String(),
|
'createdAt': createdAt.toIso8601String(),
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ class Player {
|
|||||||
final String id;
|
final String id;
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
final String name;
|
final String name;
|
||||||
|
int nameCount;
|
||||||
final String description;
|
final String description;
|
||||||
|
|
||||||
Player({
|
Player({
|
||||||
String? id,
|
String? id,
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
required this.name,
|
required this.name,
|
||||||
|
this.nameCount = 0,
|
||||||
String? description,
|
String? description,
|
||||||
}) : id = id ?? const Uuid().v4(),
|
}) : id = id ?? const Uuid().v4(),
|
||||||
createdAt = createdAt ?? clock.now(),
|
createdAt = createdAt ?? clock.now(),
|
||||||
@@ -18,7 +20,7 @@ class Player {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Player{id: $id, name: $name, description: $description}';
|
return 'Player{id: $id, createdAt: $createdAt, name: $name, nameCount: $nameCount, description: $description}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a Player instance from a JSON object.
|
/// Creates a Player instance from a JSON object.
|
||||||
@@ -26,6 +28,7 @@ class Player {
|
|||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
createdAt = DateTime.parse(json['createdAt']),
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
name = json['name'],
|
name = json['name'],
|
||||||
|
nameCount = 0,
|
||||||
description = json['description'];
|
description = json['description'];
|
||||||
|
|
||||||
/// Converts the Player instance to a JSON object.
|
/// Converts the Player instance to a JSON object.
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class Team {
|
|||||||
createdAt = DateTime.parse(json['createdAt']),
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
members = []; // Populated during import via DataTransferService
|
members = []; // Populated during import via DataTransferService
|
||||||
|
|
||||||
/// Converts the Team instance to a JSON object using normalized format (memberIds only).
|
/// Converts the Team instance to a JSON object. Related objects are
|
||||||
|
/// represented by their IDs.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tallee/core/adaptive_page_route.dart';
|
import 'package:tallee/core/adaptive_page_route.dart';
|
||||||
|
import 'package:tallee/core/common.dart';
|
||||||
import 'package:tallee/core/custom_theme.dart';
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
import 'package:tallee/data/db/database.dart';
|
import 'package:tallee/data/db/database.dart';
|
||||||
import 'package:tallee/data/models/group.dart';
|
import 'package:tallee/data/models/group.dart';
|
||||||
@@ -153,6 +154,7 @@ class _GroupDetailViewState extends State<GroupDetailView> {
|
|||||||
children: _group.members.map((member) {
|
children: _group.members.map((member) {
|
||||||
return TextIconTile(
|
return TextIconTile(
|
||||||
text: member.name,
|
text: member.name,
|
||||||
|
suffixText: getNameCountText(member),
|
||||||
iconEnabled: false,
|
iconEnabled: false,
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class _HomeViewState extends State<HomeView> {
|
|||||||
/// Updates the winner information for a specific match in the recent matches list.
|
/// Updates the winner information for a specific match in the recent matches list.
|
||||||
Future<void> updatedWinnerInRecentMatches(String matchId) async {
|
Future<void> updatedWinnerInRecentMatches(String matchId) async {
|
||||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
final winner = await db.scoreDao.getWinner(matchId: matchId);
|
final winner = await db.scoreEntryDao.getWinner(matchId: matchId);
|
||||||
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);
|
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);
|
||||||
if (matchIndex != -1) {
|
if (matchIndex != -1) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ class _MatchDetailViewState extends State<MatchDetailView> {
|
|||||||
children: match.players.map((player) {
|
children: match.players.map((player) {
|
||||||
return TextIconTile(
|
return TextIconTile(
|
||||||
text: player.name,
|
text: player.name,
|
||||||
|
suffixText: getNameCountText(player),
|
||||||
iconEnabled: false,
|
iconEnabled: false,
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ class _MatchResultViewState extends State<MatchResultView> {
|
|||||||
/// based on the current selection.
|
/// based on the current selection.
|
||||||
Future<void> _handleWinnerSaving() async {
|
Future<void> _handleWinnerSaving() async {
|
||||||
if (_selectedPlayer == null) {
|
if (_selectedPlayer == null) {
|
||||||
await db.scoreDao.removeWinner(matchId: widget.match.id);
|
await db.scoreEntryDao.removeWinner(matchId: widget.match.id);
|
||||||
} else {
|
} else {
|
||||||
await db.scoreDao.setWinner(
|
await db.scoreEntryDao.setWinner(
|
||||||
matchId: widget.match.id,
|
matchId: widget.match.id,
|
||||||
playerId: _selectedPlayer!.id,
|
playerId: _selectedPlayer!.id,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ const allDependencies = <Package>[
|
|||||||
_http_parser,
|
_http_parser,
|
||||||
_intl,
|
_intl,
|
||||||
_io,
|
_io,
|
||||||
|
_jni,
|
||||||
|
_jni_flutter,
|
||||||
_js,
|
_js,
|
||||||
_json_annotation,
|
_json_annotation,
|
||||||
_json_schema,
|
_json_schema,
|
||||||
@@ -360,13 +362,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// async 2.13.0
|
/// async 2.13.1
|
||||||
const _async = Package(
|
const _async = Package(
|
||||||
name: 'async',
|
name: 'async',
|
||||||
description: "Utility functions and classes related to the 'dart:async' library.",
|
description: "Utility functions and classes related to the 'dart:async' library.",
|
||||||
repository: 'https://github.com/dart-lang/core/tree/main/pkgs/async',
|
repository: 'https://github.com/dart-lang/core/tree/main/pkgs/async',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '2.13.0',
|
version: '2.13.1',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -442,13 +444,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// build 4.0.4
|
/// build 4.0.5
|
||||||
const _build = Package(
|
const _build = Package(
|
||||||
name: 'build',
|
name: 'build',
|
||||||
description: 'A package for authoring build_runner compatible code generators.',
|
description: 'A package for authoring build_runner compatible code generators.',
|
||||||
repository: 'https://github.com/dart-lang/build/tree/master/build',
|
repository: 'https://github.com/dart-lang/build/tree/master/build',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '4.0.4',
|
version: '4.0.5',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -565,13 +567,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// build_runner 2.12.2
|
/// build_runner 2.13.1
|
||||||
const _build_runner = Package(
|
const _build_runner = Package(
|
||||||
name: 'build_runner',
|
name: 'build_runner',
|
||||||
description: 'A build system for Dart code generation and modular compilation.',
|
description: 'A build system for Dart code generation and modular compilation.',
|
||||||
repository: 'https://github.com/dart-lang/build/tree/master/build_runner',
|
repository: 'https://github.com/dart-lang/build/tree/master/build_runner',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '2.12.2',
|
version: '2.13.1',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -649,14 +651,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// built_value 8.12.4
|
/// built_value 8.12.5
|
||||||
const _built_value = Package(
|
const _built_value = Package(
|
||||||
name: 'built_value',
|
name: 'built_value',
|
||||||
description: '''Value types with builders, Dart classes as enums, and serialization. This library is the runtime dependency.
|
description: '''Value types with builders, Dart classes as enums, and serialization. This library is the runtime dependency.
|
||||||
''',
|
''',
|
||||||
repository: 'https://github.com/google/built_value.dart/tree/master/built_value',
|
repository: 'https://github.com/google/built_value.dart/tree/master/built_value',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '8.12.4',
|
version: '8.12.5',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -1436,18 +1438,18 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// cupertino_icons 1.0.8
|
/// cupertino_icons 1.0.9
|
||||||
const _cupertino_icons = Package(
|
const _cupertino_icons = Package(
|
||||||
name: 'cupertino_icons',
|
name: 'cupertino_icons',
|
||||||
description: 'Default icons asset for Cupertino widgets based on Apple styled icons',
|
description: 'Default icons asset for Cupertino widgets based on Apple styled icons',
|
||||||
repository: 'https://github.com/flutter/packages/tree/main/third_party/packages/cupertino_icons',
|
repository: 'https://github.com/flutter/packages/tree/main/third_party/packages/cupertino_icons',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '1.0.8',
|
version: '1.0.9',
|
||||||
spdxIdentifiers: ['MIT'],
|
spdxIdentifiers: ['MIT'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
devDependencies: [PackageRef('flutter'), PackageRef('flutter_test')],
|
devDependencies: [PackageRef('collection'), PackageRef('flutter'), PackageRef('flutter_test'), PackageRef('path')],
|
||||||
license: '''The MIT License (MIT)
|
license: '''The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Vladimir Kharlampidi
|
Copyright (c) 2016 Vladimir Kharlampidi
|
||||||
@@ -2627,13 +2629,13 @@ const _flutter_localizations = Package(
|
|||||||
devDependencies: [PackageRef('flutter_test')],
|
devDependencies: [PackageRef('flutter_test')],
|
||||||
);
|
);
|
||||||
|
|
||||||
/// flutter_plugin_android_lifecycle 2.0.33
|
/// flutter_plugin_android_lifecycle 2.0.34
|
||||||
const _flutter_plugin_android_lifecycle = Package(
|
const _flutter_plugin_android_lifecycle = Package(
|
||||||
name: 'flutter_plugin_android_lifecycle',
|
name: 'flutter_plugin_android_lifecycle',
|
||||||
description: 'Flutter plugin for accessing an Android Lifecycle within other plugins.',
|
description: 'Flutter plugin for accessing an Android Lifecycle within other plugins.',
|
||||||
repository: 'https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle',
|
repository: 'https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '2.0.33',
|
version: '2.0.34',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -3173,6 +3175,88 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// jni 1.0.0
|
||||||
|
const _jni = Package(
|
||||||
|
name: 'jni',
|
||||||
|
description: 'A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.',
|
||||||
|
repository: 'https://github.com/dart-lang/native/tree/main/pkgs/jni',
|
||||||
|
authors: [],
|
||||||
|
version: '1.0.0',
|
||||||
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
|
isMarkdown: false,
|
||||||
|
isSdk: false,
|
||||||
|
dependencies: [PackageRef('args'), PackageRef('collection'), PackageRef('ffi'), PackageRef('meta'), PackageRef('package_config'), PackageRef('path'), PackageRef('plugin_platform_interface')],
|
||||||
|
devDependencies: [PackageRef('dart_style'), PackageRef('logging'), PackageRef('test')],
|
||||||
|
license: '''Copyright 2022, the Dart project authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials provided
|
||||||
|
with the distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
|
);
|
||||||
|
|
||||||
|
/// jni_flutter 1.0.1
|
||||||
|
const _jni_flutter = Package(
|
||||||
|
name: 'jni_flutter',
|
||||||
|
description: 'A library to access Flutter Android specific APIs from Dart.',
|
||||||
|
repository: 'https://github.com/dart-lang/native/tree/main/pkgs/jni_flutter',
|
||||||
|
authors: [],
|
||||||
|
version: '1.0.1',
|
||||||
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
|
isMarkdown: false,
|
||||||
|
isSdk: false,
|
||||||
|
dependencies: [PackageRef('flutter'), PackageRef('jni')],
|
||||||
|
devDependencies: [PackageRef('flutter_test')],
|
||||||
|
license: '''Copyright 2026, the Dart project authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials provided
|
||||||
|
with the distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
|
);
|
||||||
|
|
||||||
/// js 0.7.2
|
/// js 0.7.2
|
||||||
const _js = Package(
|
const _js = Package(
|
||||||
name: 'js',
|
name: 'js',
|
||||||
@@ -3511,13 +3595,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// markdown 7.3.0
|
/// markdown 7.3.1
|
||||||
const _markdown = Package(
|
const _markdown = Package(
|
||||||
name: 'markdown',
|
name: 'markdown',
|
||||||
description: 'A portable Markdown library written in Dart that can parse Markdown into HTML.',
|
description: 'A portable Markdown library written in Dart that can parse Markdown into HTML.',
|
||||||
repository: 'https://github.com/dart-lang/tools/tree/main/pkgs/markdown',
|
repository: 'https://github.com/dart-lang/tools/tree/main/pkgs/markdown',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '7.3.0',
|
version: '7.3.1',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -3890,13 +3974,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// native_toolchain_c 0.17.5
|
/// native_toolchain_c 0.17.6
|
||||||
const _native_toolchain_c = Package(
|
const _native_toolchain_c = Package(
|
||||||
name: 'native_toolchain_c',
|
name: 'native_toolchain_c',
|
||||||
description: 'A library to invoke the native C compiler installed on the host machine.',
|
description: 'A library to invoke the native C compiler installed on the host machine.',
|
||||||
repository: 'https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c',
|
repository: 'https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '0.17.5',
|
version: '0.17.6',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -4110,14 +4194,14 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// package_info_plus 9.0.0
|
/// package_info_plus 9.0.1
|
||||||
const _package_info_plus = Package(
|
const _package_info_plus = Package(
|
||||||
name: 'package_info_plus',
|
name: 'package_info_plus',
|
||||||
description: 'Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.',
|
description: 'Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.',
|
||||||
homepage: 'https://github.com/fluttercommunity/plus_plugins',
|
homepage: 'https://github.com/fluttercommunity/plus_plugins',
|
||||||
repository: 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/package_info_plus/package_info_plus',
|
repository: 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/package_info_plus/package_info_plus',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '9.0.0',
|
version: '9.0.1',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -4194,13 +4278,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// pana 0.23.10
|
/// pana 0.23.11
|
||||||
const _pana = Package(
|
const _pana = Package(
|
||||||
name: 'pana',
|
name: 'pana',
|
||||||
description: 'PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.',
|
description: 'PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.',
|
||||||
repository: 'https://github.com/dart-lang/pana',
|
repository: 'https://github.com/dart-lang/pana',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '0.23.10',
|
version: '0.23.11',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -4315,17 +4399,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// path_provider_android 2.2.22
|
/// path_provider_android 2.3.1
|
||||||
const _path_provider_android = Package(
|
const _path_provider_android = Package(
|
||||||
name: 'path_provider_android',
|
name: 'path_provider_android',
|
||||||
description: 'Android implementation of the path_provider plugin.',
|
description: 'Android implementation of the path_provider plugin.',
|
||||||
repository: 'https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider_android',
|
repository: 'https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider_android',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '2.2.22',
|
version: '2.3.1',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
dependencies: [PackageRef('flutter'), PackageRef('path_provider_platform_interface')],
|
dependencies: [PackageRef('flutter'), PackageRef('jni'), PackageRef('jni_flutter'), PackageRef('path_provider_platform_interface')],
|
||||||
devDependencies: [PackageRef('flutter_test'), PackageRef('test')],
|
devDependencies: [PackageRef('flutter_test'), PackageRef('test')],
|
||||||
license: '''Copyright 2013 The Flutter Authors
|
license: '''Copyright 2013 The Flutter Authors
|
||||||
|
|
||||||
@@ -36119,13 +36203,13 @@ Copyright (C) 2009-2017, International Business Machines Corporation,
|
|||||||
Google, and others. All Rights Reserved.''',
|
Google, and others. All Rights Reserved.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// source_gen 4.2.0
|
/// source_gen 4.2.2
|
||||||
const _source_gen = Package(
|
const _source_gen = Package(
|
||||||
name: 'source_gen',
|
name: 'source_gen',
|
||||||
description: 'Source code generation builders and utilities for the Dart build system',
|
description: 'Source code generation builders and utilities for the Dart build system',
|
||||||
repository: 'https://github.com/dart-lang/source_gen/tree/master/source_gen',
|
repository: 'https://github.com/dart-lang/source_gen/tree/master/source_gen',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '4.2.0',
|
version: '4.2.2',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -36835,13 +36919,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// url_launcher_android 6.3.28
|
/// url_launcher_android 6.3.29
|
||||||
const _url_launcher_android = Package(
|
const _url_launcher_android = Package(
|
||||||
name: 'url_launcher_android',
|
name: 'url_launcher_android',
|
||||||
description: 'Android implementation of the url_launcher plugin.',
|
description: 'Android implementation of the url_launcher plugin.',
|
||||||
repository: 'https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_android',
|
repository: 'https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_android',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '6.3.28',
|
version: '6.3.29',
|
||||||
spdxIdentifiers: ['BSD-3-Clause'],
|
spdxIdentifiers: ['BSD-3-Clause'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
@@ -37796,12 +37880,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.''',
|
SOFTWARE.''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// tallee 0.0.19+253
|
/// tallee 0.0.20+254
|
||||||
const _tallee = Package(
|
const _tallee = Package(
|
||||||
name: 'tallee',
|
name: 'tallee',
|
||||||
description: 'Tracking App for Card Games',
|
description: 'Tracking App for Card Games',
|
||||||
authors: [],
|
authors: [],
|
||||||
version: '0.0.19+253',
|
version: '0.0.20+254',
|
||||||
spdxIdentifiers: ['LGPL-3.0'],
|
spdxIdentifiers: ['LGPL-3.0'],
|
||||||
isMarkdown: false,
|
isMarkdown: false,
|
||||||
isSdk: false,
|
isSdk: false,
|
||||||
|
|||||||
@@ -18,9 +18,18 @@ class StatisticsView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _StatisticsViewState extends State<StatisticsView> {
|
class _StatisticsViewState extends State<StatisticsView> {
|
||||||
List<(String, int)> winCounts = List.filled(6, ('Skeleton Player', 1));
|
List<(Player, int)> winCounts = List.filled(6, (
|
||||||
List<(String, int)> matchCounts = List.filled(6, ('Skeleton Player', 1));
|
Player(name: 'Skeleton Player'),
|
||||||
List<(String, double)> winRates = List.filled(6, ('Skeleton Player', 1));
|
1,
|
||||||
|
));
|
||||||
|
List<(Player, int)> matchCounts = List.filled(6, (
|
||||||
|
Player(name: 'Skeleton Player'),
|
||||||
|
1,
|
||||||
|
));
|
||||||
|
List<(Player, double)> winRates = List.filled(6, (
|
||||||
|
Player(name: 'Skeleton Player'),
|
||||||
|
1,
|
||||||
|
));
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -121,7 +130,10 @@ class _StatisticsViewState extends State<StatisticsView> {
|
|||||||
players: players,
|
players: players,
|
||||||
context: context,
|
context: context,
|
||||||
);
|
);
|
||||||
winRates = computeWinRatePercent(wins: winCounts, matches: matchCounts);
|
winRates = computeWinRatePercent(
|
||||||
|
winCounts: winCounts,
|
||||||
|
matchCounts: matchCounts,
|
||||||
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
@@ -130,47 +142,47 @@ class _StatisticsViewState extends State<StatisticsView> {
|
|||||||
|
|
||||||
/// Calculates the number of wins for each player
|
/// Calculates the number of wins for each player
|
||||||
/// and returns a sorted list of tuples (playerName, winCount)
|
/// and returns a sorted list of tuples (playerName, winCount)
|
||||||
List<(String, int)> _calculateWinsForAllPlayers({
|
List<(Player, int)> _calculateWinsForAllPlayers({
|
||||||
required List<Match> matches,
|
required List<Match> matches,
|
||||||
required List<Player> players,
|
required List<Player> players,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
}) {
|
}) {
|
||||||
List<(String, int)> winCounts = [];
|
List<(Player, int)> winCounts = [];
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
|
|
||||||
// Getting the winners
|
// Getting the winners
|
||||||
for (var match in matches) {
|
for (var match in matches) {
|
||||||
final winner = match.winner;
|
final winner = match.winner;
|
||||||
if (winner != null) {
|
if (winner != null) {
|
||||||
final index = winCounts.indexWhere((entry) => entry.$1 == winner.id);
|
final index = winCounts.indexWhere((entry) => entry.$1.id == winner.id);
|
||||||
// -1 means winner not found in winCounts
|
// -1 means winner not found in winCounts
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
final current = winCounts[index].$2;
|
final current = winCounts[index].$2;
|
||||||
winCounts[index] = (winner.id, current + 1);
|
winCounts[index] = (winner, current + 1);
|
||||||
} else {
|
} else {
|
||||||
winCounts.add((winner.id, 1));
|
winCounts.add((winner, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding all players with zero wins
|
// Adding all players with zero wins
|
||||||
for (var player in players) {
|
for (var player in players) {
|
||||||
final index = winCounts.indexWhere((entry) => entry.$1 == player.id);
|
final index = winCounts.indexWhere((entry) => entry.$1.id == player.id);
|
||||||
// -1 means player not found in winCounts
|
// -1 means player not found in winCounts
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
winCounts.add((player.id, 0));
|
winCounts.add((player, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace player IDs with names
|
// Replace player IDs with names
|
||||||
for (int i = 0; i < winCounts.length; i++) {
|
for (int i = 0; i < winCounts.length; i++) {
|
||||||
final playerId = winCounts[i].$1;
|
final playerId = winCounts[i].$1.id;
|
||||||
final player = players.firstWhere(
|
final player = players.firstWhere(
|
||||||
(p) => p.id == playerId,
|
(p) => p.id == playerId,
|
||||||
orElse: () =>
|
orElse: () =>
|
||||||
Player(id: playerId, name: loc.not_available, description: ''),
|
Player(id: playerId, name: loc.not_available, description: ''),
|
||||||
);
|
);
|
||||||
winCounts[i] = (player.name, winCounts[i].$2);
|
winCounts[i] = (player, winCounts[i].$2);
|
||||||
}
|
}
|
||||||
|
|
||||||
winCounts.sort((a, b) => b.$2.compareTo(a.$2));
|
winCounts.sort((a, b) => b.$2.compareTo(a.$2));
|
||||||
@@ -180,60 +192,51 @@ class _StatisticsViewState extends State<StatisticsView> {
|
|||||||
|
|
||||||
/// Calculates the number of matches played for each player
|
/// Calculates the number of matches played for each player
|
||||||
/// and returns a sorted list of tuples (playerName, matchCount)
|
/// and returns a sorted list of tuples (playerName, matchCount)
|
||||||
List<(String, int)> _calculateMatchAmountsForAllPlayers({
|
List<(Player, int)> _calculateMatchAmountsForAllPlayers({
|
||||||
required List<Match> matches,
|
required List<Match> matches,
|
||||||
required List<Player> players,
|
required List<Player> players,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
}) {
|
}) {
|
||||||
List<(String, int)> matchCounts = [];
|
List<(Player, int)> matchCounts = [];
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
|
|
||||||
// Counting matches for each player
|
// Counting matches for each player
|
||||||
for (var match in matches) {
|
for (var match in matches) {
|
||||||
if (match.group != null) {
|
for (Player player in match.players) {
|
||||||
final members = match.group!.members.map((p) => p.id).toList();
|
// Check if the player is already in matchCounts
|
||||||
for (var playerId in members) {
|
final index = matchCounts.indexWhere(
|
||||||
final index = matchCounts.indexWhere((entry) => entry.$1 == playerId);
|
(entry) => entry.$1.id == player.id,
|
||||||
// -1 means player not found in matchCounts
|
);
|
||||||
if (index != -1) {
|
|
||||||
final current = matchCounts[index].$2;
|
// -1 -> not found
|
||||||
matchCounts[index] = (playerId, current + 1);
|
if (index == -1) {
|
||||||
} else {
|
// Add new entry
|
||||||
matchCounts.add((playerId, 1));
|
matchCounts.add((player, 1));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final members = match.players.map((p) => p.id).toList();
|
|
||||||
for (var playerId in members) {
|
|
||||||
final index = matchCounts.indexWhere((entry) => entry.$1 == playerId);
|
|
||||||
// -1 means player not found in matchCounts
|
|
||||||
if (index != -1) {
|
|
||||||
final current = matchCounts[index].$2;
|
|
||||||
matchCounts[index] = (playerId, current + 1);
|
|
||||||
} else {
|
} else {
|
||||||
matchCounts.add((playerId, 1));
|
// Update existing entry
|
||||||
|
final currentMatchAmount = matchCounts[index].$2;
|
||||||
|
matchCounts[index] = (player, currentMatchAmount + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding all players with zero matches
|
// Adding all players with zero matches
|
||||||
for (var player in players) {
|
for (var player in players) {
|
||||||
final index = matchCounts.indexWhere((entry) => entry.$1 == player.id);
|
final index = matchCounts.indexWhere((entry) => entry.$1.id == player.id);
|
||||||
// -1 means player not found in matchCounts
|
// -1 means player not found in matchCounts
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
matchCounts.add((player.id, 0));
|
matchCounts.add((player, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace player IDs with names
|
// Replace player IDs with names
|
||||||
for (int i = 0; i < matchCounts.length; i++) {
|
for (int i = 0; i < matchCounts.length; i++) {
|
||||||
final playerId = matchCounts[i].$1;
|
final playerId = matchCounts[i].$1.id;
|
||||||
final player = players.firstWhere(
|
final player = players.firstWhere(
|
||||||
(p) => p.id == playerId,
|
(p) => p.id == playerId,
|
||||||
orElse: () =>
|
orElse: () => Player(id: playerId, name: loc.not_available),
|
||||||
Player(id: playerId, name: loc.not_available, description: ''),
|
|
||||||
);
|
);
|
||||||
matchCounts[i] = (player.name, matchCounts[i].$2);
|
matchCounts[i] = (player, matchCounts[i].$2);
|
||||||
}
|
}
|
||||||
|
|
||||||
matchCounts.sort((a, b) => b.$2.compareTo(a.$2));
|
matchCounts.sort((a, b) => b.$2.compareTo(a.$2));
|
||||||
@@ -241,25 +244,24 @@ class _StatisticsViewState extends State<StatisticsView> {
|
|||||||
return matchCounts;
|
return matchCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dart
|
List<(Player, double)> computeWinRatePercent({
|
||||||
List<(String, double)> computeWinRatePercent({
|
required List<(Player, int)> winCounts,
|
||||||
required List<(String, int)> wins,
|
required List<(Player, int)> matchCounts,
|
||||||
required List<(String, int)> matches,
|
|
||||||
}) {
|
}) {
|
||||||
final Map<String, int> winsMap = {for (var e in wins) e.$1: e.$2};
|
final Map<Player, int> winsMap = {for (var e in winCounts) e.$1: e.$2};
|
||||||
final Map<String, int> matchesMap = {for (var e in matches) e.$1: e.$2};
|
final Map<Player, int> matchesMap = {for (var e in matchCounts) e.$1: e.$2};
|
||||||
|
|
||||||
// Get all unique player names
|
// Get all unique player names
|
||||||
final names = {...winsMap.keys, ...matchesMap.keys};
|
final player = {...matchesMap.keys};
|
||||||
|
|
||||||
// Calculate win rates
|
// Calculate win rates
|
||||||
final result = names.map((name) {
|
final result = player.map((name) {
|
||||||
final int w = winsMap[name] ?? 0;
|
final int w = winsMap[name] ?? 0;
|
||||||
final int g = matchesMap[name] ?? 0;
|
final int m = matchesMap[name] ?? 0;
|
||||||
// Calculate percentage and round to 2 decimal places
|
// Calculate percentage and round to 2 decimal places
|
||||||
// Avoid division by zero
|
// Avoid division by zero
|
||||||
final double percent = (g > 0)
|
final double percent = (m > 0)
|
||||||
? double.parse(((w / g)).toStringAsFixed(2))
|
? double.parse(((w / m)).toStringAsFixed(2))
|
||||||
: 0;
|
: 0;
|
||||||
return (name, percent);
|
return (name, percent);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tallee/core/common.dart';
|
||||||
import 'package:tallee/core/constants.dart';
|
import 'package:tallee/core/constants.dart';
|
||||||
import 'package:tallee/core/custom_theme.dart';
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
import 'package:tallee/data/db/database.dart';
|
import 'package:tallee/data/db/database.dart';
|
||||||
@@ -140,6 +141,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
padding: const EdgeInsets.only(right: 8.0),
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
child: TextIconTile(
|
child: TextIconTile(
|
||||||
text: player.name,
|
text: player.name,
|
||||||
|
suffixText: getNameCountText(player),
|
||||||
onIconTap: () {
|
onIconTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
// Removes the player from the selection and notifies the parent.
|
// Removes the player from the selection and notifies the parent.
|
||||||
@@ -193,6 +195,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return TextIconListTile(
|
return TextIconListTile(
|
||||||
text: suggestedPlayers[index].name,
|
text: suggestedPlayers[index].name,
|
||||||
|
suffixText: getNameCountText(suggestedPlayers[index]),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
// If the player is not already selected
|
// If the player is not already selected
|
||||||
@@ -282,7 +285,8 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
final playerName = _searchBarController.text.trim();
|
final playerName = _searchBarController.text.trim();
|
||||||
|
|
||||||
final createdPlayer = Player(name: playerName, description: '');
|
int nameCount = _calculateNameCount(playerName);
|
||||||
|
final createdPlayer = Player(name: playerName, nameCount: nameCount);
|
||||||
final success = await db.playerDao.addPlayer(player: createdPlayer);
|
final success = await db.playerDao.addPlayer(player: createdPlayer);
|
||||||
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
@@ -295,6 +299,22 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _calculateNameCount(String playerName) {
|
||||||
|
final playersWithSameName =
|
||||||
|
allPlayers.where((player) => player.name == playerName).toList()
|
||||||
|
..sort((a, b) => a.nameCount.compareTo(b.nameCount));
|
||||||
|
|
||||||
|
if (playersWithSameName.isEmpty) {
|
||||||
|
return 0;
|
||||||
|
} else if (playersWithSameName.length == 1) {
|
||||||
|
// Initialize nameCount
|
||||||
|
playersWithSameName[0].nameCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return following count
|
||||||
|
return playersWithSameName.length + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/// Updates the state after successfully adding a new player.
|
/// Updates the state after successfully adding a new player.
|
||||||
void _handleSuccessfulPlayerCreation(Player player) {
|
void _handleSuccessfulPlayerCreation(Player player) {
|
||||||
selectedPlayers.insert(0, player);
|
selectedPlayers.insert(0, player);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tallee/core/common.dart';
|
||||||
import 'package:tallee/core/custom_theme.dart';
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
import 'package:tallee/data/models/group.dart';
|
import 'package:tallee/data/models/group.dart';
|
||||||
import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart';
|
import 'package:tallee/presentation/widgets/tiles/text_icon_tile.dart';
|
||||||
@@ -81,7 +82,11 @@ class _GroupTileState extends State<GroupTile> {
|
|||||||
for (var member in [
|
for (var member in [
|
||||||
...widget.group.members,
|
...widget.group.members,
|
||||||
]..sort((a, b) => a.name.compareTo(b.name)))
|
]..sort((a, b) => a.name.compareTo(b.name)))
|
||||||
TextIconTile(text: member.name, iconEnabled: false),
|
TextIconTile(
|
||||||
|
text: member.name,
|
||||||
|
suffixText: getNameCountText(member),
|
||||||
|
iconEnabled: false,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2.5),
|
const SizedBox(height: 2.5),
|
||||||
|
|||||||
@@ -203,7 +203,11 @@ class _MatchTileState extends State<MatchTile> {
|
|||||||
spacing: 6,
|
spacing: 6,
|
||||||
runSpacing: 6,
|
runSpacing: 6,
|
||||||
children: players.map((player) {
|
children: players.map((player) {
|
||||||
return TextIconTile(text: player.name, iconEnabled: false);
|
return TextIconTile(
|
||||||
|
text: player.name,
|
||||||
|
suffixText: getNameCountText(player),
|
||||||
|
iconEnabled: false,
|
||||||
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tallee/core/common.dart';
|
||||||
|
import 'package:tallee/core/custom_theme.dart';
|
||||||
|
import 'package:tallee/data/models/player.dart';
|
||||||
import 'package:tallee/l10n/generated/app_localizations.dart';
|
import 'package:tallee/l10n/generated/app_localizations.dart';
|
||||||
import 'package:tallee/presentation/widgets/tiles/info_tile.dart';
|
import 'package:tallee/presentation/widgets/tiles/info_tile.dart';
|
||||||
|
|
||||||
@@ -32,7 +35,7 @@ class StatisticsTile extends StatelessWidget {
|
|||||||
final double width;
|
final double width;
|
||||||
|
|
||||||
/// A list of tuples containing labels and their corresponding numeric values.
|
/// A list of tuples containing labels and their corresponding numeric values.
|
||||||
final List<(String, num)> values;
|
final List<(Player, num)> values;
|
||||||
|
|
||||||
/// The maximum number of items to display.
|
/// The maximum number of items to display.
|
||||||
final int itemCount;
|
final int itemCount;
|
||||||
@@ -89,11 +92,29 @@ class StatisticsTile extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 4.0),
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
child: Text(
|
child: RichText(
|
||||||
values[index].$1,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
text: TextSpan(
|
||||||
fontSize: 16,
|
style: DefaultTextStyle.of(context).style,
|
||||||
fontWeight: FontWeight.bold,
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: values[index].$1.name,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: getNameCountText(values[index].$1),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: CustomTheme.textColor.withAlpha(
|
||||||
|
150,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class TextIconListTile extends StatelessWidget {
|
|||||||
const TextIconListTile({
|
const TextIconListTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
|
this.suffixText = '',
|
||||||
this.iconEnabled = true,
|
this.iconEnabled = true,
|
||||||
this.onPressed,
|
this.onPressed,
|
||||||
});
|
});
|
||||||
@@ -16,6 +17,9 @@ class TextIconListTile extends StatelessWidget {
|
|||||||
/// The text to display in the tile.
|
/// The text to display in the tile.
|
||||||
final String text;
|
final String text;
|
||||||
|
|
||||||
|
/// An optional suffix text to display after the main text.
|
||||||
|
final String suffixText;
|
||||||
|
|
||||||
/// A boolean to determine if the icon should be displayed.
|
/// A boolean to determine if the icon should be displayed.
|
||||||
final bool iconEnabled;
|
final bool iconEnabled;
|
||||||
|
|
||||||
@@ -35,12 +39,27 @@ class TextIconListTile extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.5),
|
padding: const EdgeInsets.symmetric(vertical: 12.5),
|
||||||
child: Text(
|
child: RichText(
|
||||||
text,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
text: TextSpan(
|
||||||
fontSize: 16,
|
style: DefaultTextStyle.of(context).style,
|
||||||
fontWeight: FontWeight.w500,
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: text,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: suffixText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: CustomTheme.textColor.withAlpha(100),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class TextIconTile extends StatelessWidget {
|
|||||||
const TextIconTile({
|
const TextIconTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
|
this.suffixText = '',
|
||||||
this.iconEnabled = true,
|
this.iconEnabled = true,
|
||||||
this.onIconTap,
|
this.onIconTap,
|
||||||
});
|
});
|
||||||
@@ -16,6 +17,8 @@ class TextIconTile extends StatelessWidget {
|
|||||||
/// The text to display in the tile.
|
/// The text to display in the tile.
|
||||||
final String text;
|
final String text;
|
||||||
|
|
||||||
|
final String suffixText;
|
||||||
|
|
||||||
/// A boolean to determine if the icon should be displayed.
|
/// A boolean to determine if the icon should be displayed.
|
||||||
final bool iconEnabled;
|
final bool iconEnabled;
|
||||||
|
|
||||||
@@ -36,10 +39,28 @@ class TextIconTile extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
if (iconEnabled) const SizedBox(width: 3),
|
if (iconEnabled) const SizedBox(width: 3),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: RichText(
|
||||||
text,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
text: TextSpan(
|
||||||
|
style: DefaultTextStyle.of(context).style,
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: text,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: suffixText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: CustomTheme.textColor.withAlpha(120),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (iconEnabled) ...<Widget>[
|
if (iconEnabled) ...<Widget>[
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class DataTransferService {
|
|||||||
/// Deletes all data from the database.
|
/// Deletes all data from the database.
|
||||||
static Future<void> deleteAllData(BuildContext context) async {
|
static Future<void> deleteAllData(BuildContext context) async {
|
||||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||||
|
|
||||||
await db.matchDao.deleteAllMatches();
|
await db.matchDao.deleteAllMatches();
|
||||||
await db.teamDao.deleteAllTeams();
|
await db.teamDao.deleteAllTeams();
|
||||||
await db.groupDao.deleteAllGroups();
|
await db.groupDao.deleteAllGroups();
|
||||||
@@ -96,8 +97,8 @@ class DataTransferService {
|
|||||||
/// Exports the given JSON string to a file with the specified name.
|
/// Exports the given JSON string to a file with the specified name.
|
||||||
/// Returns an [ExportResult] indicating the outcome.
|
/// Returns an [ExportResult] indicating the outcome.
|
||||||
///
|
///
|
||||||
/// [jsonString] The JSON string to be exported.
|
/// - [jsonString]: The JSON string to be exported.
|
||||||
/// [fileName] The desired name for the exported file (without extension).
|
/// - [fileName]: The desired name for the exported file (without extension).
|
||||||
static Future<ExportResult> exportData(
|
static Future<ExportResult> exportData(
|
||||||
String jsonString,
|
String jsonString,
|
||||||
String fileName,
|
String fileName,
|
||||||
@@ -163,21 +164,22 @@ class DataTransferService {
|
|||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static Future<void> importDataToDatabase(
|
static Future<void> importDataToDatabase(
|
||||||
AppDatabase db,
|
AppDatabase db,
|
||||||
Map<String, dynamic> decoded,
|
Map<String, dynamic> decodedJson,
|
||||||
) async {
|
) async {
|
||||||
final importedPlayers = parsePlayersFromJson(decoded);
|
// Fetch all entities first to create lookup maps for relationships
|
||||||
|
final importedPlayers = parsePlayersFromJson(decodedJson);
|
||||||
final playerById = {for (final p in importedPlayers) p.id: p};
|
final playerById = {for (final p in importedPlayers) p.id: p};
|
||||||
|
|
||||||
final importedGames = parseGamesFromJson(decoded);
|
final importedGames = parseGamesFromJson(decodedJson);
|
||||||
final gameById = {for (final g in importedGames) g.id: g};
|
final gameById = {for (final g in importedGames) g.id: g};
|
||||||
|
|
||||||
final importedGroups = parseGroupsFromJson(decoded, playerById);
|
final importedGroups = parseGroupsFromJson(decodedJson, playerById);
|
||||||
final groupById = {for (final g in importedGroups) g.id: g};
|
final groupById = {for (final g in importedGroups) g.id: g};
|
||||||
|
|
||||||
final importedTeams = parseTeamsFromJson(decoded, playerById);
|
final importedTeams = parseTeamsFromJson(decodedJson, playerById);
|
||||||
|
|
||||||
final importedMatches = parseMatchesFromJson(
|
final importedMatches = parseMatchesFromJson(
|
||||||
decoded,
|
decodedJson,
|
||||||
gameById,
|
gameById,
|
||||||
groupById,
|
groupById,
|
||||||
playerById,
|
playerById,
|
||||||
@@ -190,31 +192,30 @@ class DataTransferService {
|
|||||||
await db.matchDao.addMatchAsList(matches: importedMatches);
|
await db.matchDao.addMatchAsList(matches: importedMatches);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses players from JSON data.
|
/* Parsing Methods */
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<Player> parsePlayersFromJson(Map<String, dynamic> decoded) {
|
static List<Player> parsePlayersFromJson(Map<String, dynamic> decodedJson) {
|
||||||
final playersJson = (decoded['players'] as List<dynamic>?) ?? [];
|
final playersJson = (decodedJson['players'] as List<dynamic>?) ?? [];
|
||||||
return playersJson
|
return playersJson
|
||||||
.map((p) => Player.fromJson(p as Map<String, dynamic>))
|
.map((p) => Player.fromJson(p as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses games from JSON data.
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<Game> parseGamesFromJson(Map<String, dynamic> decoded) {
|
static List<Game> parseGamesFromJson(Map<String, dynamic> decodedJson) {
|
||||||
final gamesJson = (decoded['games'] as List<dynamic>?) ?? [];
|
final gamesJson = (decodedJson['games'] as List<dynamic>?) ?? [];
|
||||||
return gamesJson
|
return gamesJson
|
||||||
.map((g) => Game.fromJson(g as Map<String, dynamic>))
|
.map((g) => Game.fromJson(g as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses groups from JSON data.
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<Group> parseGroupsFromJson(
|
static List<Group> parseGroupsFromJson(
|
||||||
Map<String, dynamic> decoded,
|
Map<String, dynamic> decodedJson,
|
||||||
Map<String, Player> playerById,
|
Map<String, Player> playerById,
|
||||||
) {
|
) {
|
||||||
final groupsJson = (decoded['groups'] as List<dynamic>?) ?? [];
|
final groupsJson = (decodedJson['groups'] as List<dynamic>?) ?? [];
|
||||||
return groupsJson.map((g) {
|
return groupsJson.map((g) {
|
||||||
final map = g as Map<String, dynamic>;
|
final map = g as Map<String, dynamic>;
|
||||||
final memberIds = (map['memberIds'] as List<dynamic>? ?? [])
|
final memberIds = (map['memberIds'] as List<dynamic>? ?? [])
|
||||||
@@ -238,10 +239,10 @@ class DataTransferService {
|
|||||||
/// Parses teams from JSON data.
|
/// Parses teams from JSON data.
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<Team> parseTeamsFromJson(
|
static List<Team> parseTeamsFromJson(
|
||||||
Map<String, dynamic> decoded,
|
Map<String, dynamic> decodedJson,
|
||||||
Map<String, Player> playerById,
|
Map<String, Player> playerById,
|
||||||
) {
|
) {
|
||||||
final teamsJson = (decoded['teams'] as List<dynamic>?) ?? [];
|
final teamsJson = (decodedJson['teams'] as List<dynamic>?) ?? [];
|
||||||
return teamsJson.map((t) {
|
return teamsJson.map((t) {
|
||||||
final map = t as Map<String, dynamic>;
|
final map = t as Map<String, dynamic>;
|
||||||
final memberIds = (map['memberIds'] as List<dynamic>? ?? [])
|
final memberIds = (map['memberIds'] as List<dynamic>? ?? [])
|
||||||
@@ -264,46 +265,53 @@ class DataTransferService {
|
|||||||
/// Parses matches from JSON data.
|
/// Parses matches from JSON data.
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static List<Match> parseMatchesFromJson(
|
static List<Match> parseMatchesFromJson(
|
||||||
Map<String, dynamic> decoded,
|
Map<String, dynamic> decodedJson,
|
||||||
Map<String, Game> gameById,
|
Map<String, Game> gamesMap,
|
||||||
Map<String, Group> groupById,
|
Map<String, Group> groupsMap,
|
||||||
Map<String, Player> playerById,
|
Map<String, Player> playersMap,
|
||||||
) {
|
) {
|
||||||
final matchesJson = (decoded['matches'] as List<dynamic>?) ?? [];
|
final matchesJson = (decodedJson['matches'] as List<dynamic>?) ?? [];
|
||||||
return matchesJson.map((m) {
|
return matchesJson.map((m) {
|
||||||
final map = m as Map<String, dynamic>;
|
final map = m as Map<String, dynamic>;
|
||||||
|
|
||||||
|
// Extract attributes from json
|
||||||
|
final id = map['id'] as String;
|
||||||
|
final name = map['name'] as String;
|
||||||
final gameId = map['gameId'] as String;
|
final gameId = map['gameId'] as String;
|
||||||
final groupId = map['groupId'] as String?;
|
final groupId = map['groupId'] as String?;
|
||||||
final playerIds = (map['playerIds'] as List<dynamic>? ?? [])
|
final createdAt = DateTime.parse(map['createdAt'] as String);
|
||||||
.cast<String>();
|
|
||||||
final endedAt = map['endedAt'] != null
|
final endedAt = map['endedAt'] != null
|
||||||
? DateTime.parse(map['endedAt'] as String)
|
? DateTime.parse(map['endedAt'] as String)
|
||||||
: null;
|
: null;
|
||||||
|
final notes = map['notes'] as String? ?? '';
|
||||||
|
|
||||||
final game = gameById[gameId] ?? createUnknownGame();
|
// Link attributes to objects
|
||||||
final group = groupId != null ? groupById[groupId] : null;
|
final game = gamesMap[gameId] ?? getFallbackGame();
|
||||||
|
final group = groupId != null ? groupsMap[groupId] : null;
|
||||||
|
|
||||||
|
final playerIds = (map['playerIds'] as List<dynamic>? ?? [])
|
||||||
|
.cast<String>();
|
||||||
final players = playerIds
|
final players = playerIds
|
||||||
.map((id) => playerById[id])
|
.map((id) => playersMap[id])
|
||||||
.whereType<Player>()
|
.whereType<Player>()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return Match(
|
return Match(
|
||||||
id: map['id'] as String,
|
id: id,
|
||||||
name: map['name'] as String,
|
name: name,
|
||||||
game: game,
|
game: game,
|
||||||
group: group,
|
group: group,
|
||||||
players: players,
|
players: players,
|
||||||
createdAt: DateTime.parse(map['createdAt'] as String),
|
createdAt: createdAt,
|
||||||
endedAt: endedAt,
|
endedAt: endedAt,
|
||||||
notes: map['notes'] as String? ?? '',
|
notes: notes,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a fallback game when the referenced game is not found.
|
/// Creates a fallback game when the referenced game is not found.
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static Game createUnknownGame() {
|
static Game getFallbackGame() {
|
||||||
return Game(
|
return Game(
|
||||||
name: 'Unknown',
|
name: 'Unknown',
|
||||||
ruleset: Ruleset.singleWinner,
|
ruleset: Ruleset.singleWinner,
|
||||||
@@ -320,7 +328,8 @@ class DataTransferService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates the given JSON string against the predefined schema.
|
/// Validates the given JSON string against the schema
|
||||||
|
/// in `assets/schema.json`.
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static Future<bool> validateJsonSchema(String jsonString) async {
|
static Future<bool> validateJsonSchema(String jsonString) async {
|
||||||
final String schemaString;
|
final String schemaString;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: tallee
|
name: tallee
|
||||||
description: "Tracking App for Card Games"
|
description: "Tracking App for Card Games"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.0.19+253
|
version: 0.0.20+254
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ void main() {
|
|||||||
test('Setting a winner works correctly', () async {
|
test('Setting a winner works correctly', () async {
|
||||||
await database.matchDao.addMatch(match: testMatch1);
|
await database.matchDao.addMatch(match: testMatch1);
|
||||||
|
|
||||||
await database.scoreDao.setWinner(
|
await database.scoreEntryDao.setWinner(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
playerId: testPlayer5.id,
|
playerId: testPlayer5.id,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:clock/clock.dart';
|
import 'package:clock/clock.dart';
|
||||||
import 'package:drift/drift.dart' hide isNull;
|
import 'package:drift/drift.dart' hide isNull, isNotNull;
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:tallee/data/db/database.dart';
|
import 'package:tallee/data/db/database.dart';
|
||||||
@@ -381,5 +381,160 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(playerExists, true);
|
expect(playerExists, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('Name Count Tests', () {
|
||||||
|
test('Single player gets initialized wih name count 0', () async {
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
|
||||||
|
final player = await database.playerDao.getPlayerById(
|
||||||
|
playerId: testPlayer1.id,
|
||||||
|
);
|
||||||
|
expect(player.nameCount, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple players get initialized wih name count 0', () async {
|
||||||
|
await database.playerDao.addPlayersAsList(
|
||||||
|
players: [testPlayer1, testPlayer2],
|
||||||
|
);
|
||||||
|
|
||||||
|
final players = await database.playerDao.getAllPlayers();
|
||||||
|
|
||||||
|
expect(players.length, 2);
|
||||||
|
for (Player p in players) {
|
||||||
|
expect(p.nameCount, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'Seperatly added players nameCount gets increased correctly',
|
||||||
|
() async {
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
|
||||||
|
final player1 = Player(name: testPlayer1.name, description: '');
|
||||||
|
await database.playerDao.addPlayer(player: player1);
|
||||||
|
|
||||||
|
var players = await database.playerDao.getAllPlayers();
|
||||||
|
|
||||||
|
expect(players.length, 2);
|
||||||
|
players.sort((a, b) => a.nameCount.compareTo(b.nameCount));
|
||||||
|
|
||||||
|
for (int i = 0; i < players.length - 1; i++) {
|
||||||
|
expect(players[i].nameCount, i + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'Together added players nameCount gets increased correctly',
|
||||||
|
() async {
|
||||||
|
final player1 = Player(name: testPlayer1.name, description: '');
|
||||||
|
final player2 = Player(name: testPlayer1.name, description: '');
|
||||||
|
final player3 = Player(name: testPlayer1.name, description: '');
|
||||||
|
|
||||||
|
// addPlayersAsList() with multiple players and with one player
|
||||||
|
await database.playerDao.addPlayersAsList(players: [testPlayer1]);
|
||||||
|
await database.playerDao.addPlayersAsList(
|
||||||
|
players: [player1, player2, player3],
|
||||||
|
);
|
||||||
|
|
||||||
|
var players = await database.playerDao.getAllPlayers();
|
||||||
|
|
||||||
|
expect(players.length, 4);
|
||||||
|
players.sort((a, b) => a.nameCount.compareTo(b.nameCount));
|
||||||
|
|
||||||
|
for (int i = 0; i < players.length - 1; i++) {
|
||||||
|
expect(players[i].nameCount, i + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('getNameCount works correctly', () async {
|
||||||
|
final player2 = Player(name: testPlayer1.name);
|
||||||
|
final player3 = Player(name: testPlayer1.name);
|
||||||
|
|
||||||
|
await database.playerDao.addPlayersAsList(
|
||||||
|
players: [testPlayer1, player2, player3],
|
||||||
|
);
|
||||||
|
|
||||||
|
final nameCount = await database.playerDao.getNameCount(
|
||||||
|
name: testPlayer1.name,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(nameCount, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('updateNameCount works correctly', () async {
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
|
||||||
|
final success = await database.playerDao.updateNameCount(
|
||||||
|
playerId: testPlayer1.id,
|
||||||
|
nameCount: 2,
|
||||||
|
);
|
||||||
|
expect(success, true);
|
||||||
|
|
||||||
|
final player = await database.playerDao.getPlayerById(
|
||||||
|
playerId: testPlayer1.id,
|
||||||
|
);
|
||||||
|
expect(player.nameCount, 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getPlayerWithHighestNameCount works correctly', () async {
|
||||||
|
final player2 = Player(name: testPlayer1.name, description: '');
|
||||||
|
final player3 = Player(name: testPlayer1.name, description: '');
|
||||||
|
|
||||||
|
await database.playerDao.addPlayersAsList(
|
||||||
|
players: [testPlayer1, player2, player3],
|
||||||
|
);
|
||||||
|
|
||||||
|
final player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||||
|
name: testPlayer1.name,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(player, isNotNull);
|
||||||
|
expect(player!.nameCount, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getPlayerWithHighestNameCount with non existing player', () async {
|
||||||
|
final player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||||
|
name: 'non-existing-name',
|
||||||
|
);
|
||||||
|
expect(player, isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('calculateNameCount works correctly', () async {
|
||||||
|
// Case 1: No existing players with the name
|
||||||
|
var count = await database.playerDao.calculateNameCount(
|
||||||
|
name: testPlayer1.name,
|
||||||
|
);
|
||||||
|
expect(count, 0);
|
||||||
|
|
||||||
|
// Case 2: One existing player with the name. Should update that
|
||||||
|
// player's nameCount to 1 and return 2 for the new player
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
|
||||||
|
count = await database.playerDao.calculateNameCount(
|
||||||
|
name: testPlayer1.name,
|
||||||
|
);
|
||||||
|
expect(count, 2);
|
||||||
|
|
||||||
|
// Case 3: Multiple existing players with the name.
|
||||||
|
final player2 = Player(name: testPlayer1.name, nameCount: count);
|
||||||
|
await database.playerDao.addPlayer(player: player2);
|
||||||
|
|
||||||
|
count = await database.playerDao.calculateNameCount(
|
||||||
|
name: testPlayer1.name,
|
||||||
|
);
|
||||||
|
expect(count, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getPlayerWithHighestNameCount with non existing player', () async {
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
await database.playerDao.initializeNameCount(name: testPlayer1.name);
|
||||||
|
final player = await database.playerDao.getPlayerById(
|
||||||
|
playerId: testPlayer1.id,
|
||||||
|
);
|
||||||
|
expect(player.nameCount, 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,13 @@ void main() {
|
|||||||
group('Adding and Fetching scores', () {
|
group('Adding and Fetching scores', () {
|
||||||
test('Single Score', () async {
|
test('Single Score', () async {
|
||||||
ScoreEntry entry = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry,
|
entry: entry,
|
||||||
);
|
);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -95,13 +95,13 @@ void main() {
|
|||||||
ScoreEntry(roundNumber: 3, score: 18, change: 6),
|
ScoreEntry(roundNumber: 3, score: 18, change: 6),
|
||||||
];
|
];
|
||||||
|
|
||||||
await database.scoreDao.addScoresAsList(
|
await database.scoreEntryDao.addScoresAsList(
|
||||||
entrys: entryList,
|
entrys: entryList,
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
final scores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final scores = await database.scoreEntryDao.getAllPlayerScoresInMatch(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
@@ -120,13 +120,13 @@ void main() {
|
|||||||
group('Undesirable values', () {
|
group('Undesirable values', () {
|
||||||
test('Score & Round can have negative values', () async {
|
test('Score & Round can have negative values', () async {
|
||||||
ScoreEntry entry = ScoreEntry(roundNumber: -2, score: -10, change: -10);
|
ScoreEntry entry = ScoreEntry(roundNumber: -2, score: -10, change: -10);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry,
|
entry: entry,
|
||||||
);
|
);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: -2,
|
roundNumber: -2,
|
||||||
@@ -140,13 +140,13 @@ void main() {
|
|||||||
|
|
||||||
test('Score & Round can have zero values', () async {
|
test('Score & Round can have zero values', () async {
|
||||||
ScoreEntry entry = ScoreEntry(roundNumber: 0, score: 0, change: 0);
|
ScoreEntry entry = ScoreEntry(roundNumber: 0, score: 0, change: 0);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry,
|
entry: entry,
|
||||||
);
|
);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 0,
|
roundNumber: 0,
|
||||||
@@ -158,7 +158,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Getting score for a non-existent entities returns null', () async {
|
test('Getting score for a non-existent entities returns null', () async {
|
||||||
var score = await database.scoreDao.getScore(
|
var score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: -1,
|
roundNumber: -1,
|
||||||
@@ -166,14 +166,14 @@ void main() {
|
|||||||
|
|
||||||
expect(score, isNull);
|
expect(score, isNull);
|
||||||
|
|
||||||
score = await database.scoreDao.getScore(
|
score = await database.scoreEntryDao.getScore(
|
||||||
playerId: 'non-existin-player',
|
playerId: 'non-existin-player',
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(score, isNull);
|
expect(score, isNull);
|
||||||
|
|
||||||
score = await database.scoreDao.getScore(
|
score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: 'non-existing-match',
|
matchId: 'non-existing-match',
|
||||||
);
|
);
|
||||||
@@ -183,19 +183,19 @@ void main() {
|
|||||||
|
|
||||||
test('Getting score for a non-match player returns null', () async {
|
test('Getting score for a non-match player returns null', () async {
|
||||||
ScoreEntry entry = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry,
|
entry: entry,
|
||||||
);
|
);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer3.id,
|
playerId: testPlayer3.id,
|
||||||
matchId: testMatch2.id,
|
matchId: testMatch2.id,
|
||||||
entry: entry,
|
entry: entry,
|
||||||
);
|
);
|
||||||
|
|
||||||
var score = await database.scoreDao.getScore(
|
var score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch2.id,
|
matchId: testMatch2.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -210,23 +210,23 @@ void main() {
|
|||||||
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
ScoreEntry entry2 = ScoreEntry(roundNumber: 1, score: 20, change: 20);
|
ScoreEntry entry2 = ScoreEntry(roundNumber: 1, score: 20, change: 20);
|
||||||
ScoreEntry entry3 = ScoreEntry(roundNumber: 2, score: 25, change: 15);
|
ScoreEntry entry3 = ScoreEntry(roundNumber: 2, score: 25, change: 15);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry1,
|
entry: entry1,
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer2.id,
|
playerId: testPlayer2.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry2,
|
entry: entry2,
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry3,
|
entry: entry3,
|
||||||
);
|
);
|
||||||
|
|
||||||
final scores = await database.scoreDao.getAllMatchScores(
|
final scores = await database.scoreEntryDao.getAllMatchScores(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getAllMatchScores() with no scores saved', () async {
|
test('getAllMatchScores() with no scores saved', () async {
|
||||||
final scores = await database.scoreDao.getAllMatchScores(
|
final scores = await database.scoreEntryDao.getAllMatchScores(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -247,21 +247,22 @@ void main() {
|
|||||||
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
ScoreEntry entry2 = ScoreEntry(roundNumber: 2, score: 25, change: 15);
|
ScoreEntry entry2 = ScoreEntry(roundNumber: 2, score: 25, change: 15);
|
||||||
ScoreEntry entry3 = ScoreEntry(roundNumber: 1, score: 30, change: 30);
|
ScoreEntry entry3 = ScoreEntry(roundNumber: 1, score: 30, change: 30);
|
||||||
await database.scoreDao.addScoresAsList(
|
await database.scoreEntryDao.addScoresAsList(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entrys: [entry1, entry2],
|
entrys: [entry1, entry2],
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer2.id,
|
playerId: testPlayer2.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry3,
|
entry: entry3,
|
||||||
);
|
);
|
||||||
|
|
||||||
final playerScores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final playerScores = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
|
|
||||||
expect(playerScores.length, 2);
|
expect(playerScores.length, 2);
|
||||||
expect(playerScores[0].roundNumber, 1);
|
expect(playerScores[0].roundNumber, 1);
|
||||||
@@ -273,10 +274,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getAllPlayerScoresInMatch() with no scores saved', () async {
|
test('getAllPlayerScoresInMatch() with no scores saved', () async {
|
||||||
final playerScores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final playerScores = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
|
|
||||||
expect(playerScores.isEmpty, true);
|
expect(playerScores.isEmpty, true);
|
||||||
});
|
});
|
||||||
@@ -284,30 +286,32 @@ void main() {
|
|||||||
test('Scores are isolated across different matches', () async {
|
test('Scores are isolated across different matches', () async {
|
||||||
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
ScoreEntry entry2 = ScoreEntry(roundNumber: 1, score: 50, change: 50);
|
ScoreEntry entry2 = ScoreEntry(roundNumber: 1, score: 50, change: 50);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry1,
|
entry: entry1,
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch2.id,
|
matchId: testMatch2.id,
|
||||||
entry: entry2,
|
entry: entry2,
|
||||||
);
|
);
|
||||||
|
|
||||||
final match1Scores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final match1Scores = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
|
|
||||||
expect(match1Scores.length, 1);
|
expect(match1Scores.length, 1);
|
||||||
expect(match1Scores[0].score, 10);
|
expect(match1Scores[0].score, 10);
|
||||||
expect(match1Scores[0].change, 10);
|
expect(match1Scores[0].change, 10);
|
||||||
|
|
||||||
final match2Scores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final match2Scores = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch2.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch2.id,
|
||||||
|
);
|
||||||
|
|
||||||
expect(match2Scores.length, 1);
|
expect(match2Scores.length, 1);
|
||||||
expect(match2Scores[0].score, 50);
|
expect(match2Scores[0].score, 50);
|
||||||
@@ -319,19 +323,19 @@ void main() {
|
|||||||
test('updateScore()', () async {
|
test('updateScore()', () async {
|
||||||
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
ScoreEntry entry1 = ScoreEntry(roundNumber: 1, score: 10, change: 10);
|
||||||
ScoreEntry entry2 = ScoreEntry(roundNumber: 2, score: 15, change: 5);
|
ScoreEntry entry2 = ScoreEntry(roundNumber: 2, score: 15, change: 5);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry1,
|
entry: entry1,
|
||||||
);
|
);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: entry2,
|
entry: entry2,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updated = await database.scoreDao.updateScore(
|
final updated = await database.scoreEntryDao.updateScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newEntry: ScoreEntry(roundNumber: 2, score: 50, change: 40),
|
newEntry: ScoreEntry(roundNumber: 2, score: 50, change: 40),
|
||||||
@@ -339,7 +343,7 @@ void main() {
|
|||||||
|
|
||||||
expect(updated, true);
|
expect(updated, true);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 2,
|
roundNumber: 2,
|
||||||
@@ -351,7 +355,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Updating a non-existent score returns false', () async {
|
test('Updating a non-existent score returns false', () async {
|
||||||
final updated = await database.scoreDao.updateScore(
|
final updated = await database.scoreEntryDao.updateScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newEntry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
newEntry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
||||||
@@ -363,13 +367,13 @@ void main() {
|
|||||||
|
|
||||||
group('Deleting scores', () {
|
group('Deleting scores', () {
|
||||||
test('deleteScore() ', () async {
|
test('deleteScore() ', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
|
|
||||||
final deleted = await database.scoreDao.deleteScore(
|
final deleted = await database.scoreEntryDao.deleteScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -377,7 +381,7 @@ void main() {
|
|||||||
|
|
||||||
expect(deleted, true);
|
expect(deleted, true);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -387,7 +391,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Deleting a non-existent score returns false', () async {
|
test('Deleting a non-existent score returns false', () async {
|
||||||
final deleted = await database.scoreDao.deleteScore(
|
final deleted = await database.scoreEntryDao.deleteScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -397,127 +401,130 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('deleteAllScoresForMatch() works correctly', () async {
|
test('deleteAllScoresForMatch() works correctly', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer2.id,
|
playerId: testPlayer2.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
entry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch2.id,
|
matchId: testMatch2.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 15, change: 15),
|
entry: ScoreEntry(roundNumber: 1, score: 15, change: 15),
|
||||||
);
|
);
|
||||||
|
|
||||||
final deleted = await database.scoreDao.deleteAllScoresForMatch(
|
final deleted = await database.scoreEntryDao.deleteAllScoresForMatch(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(deleted, true);
|
expect(deleted, true);
|
||||||
|
|
||||||
final match1Scores = await database.scoreDao.getAllMatchScores(
|
final match1Scores = await database.scoreEntryDao.getAllMatchScores(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(match1Scores.length, 0);
|
expect(match1Scores.length, 0);
|
||||||
|
|
||||||
final match2Scores = await database.scoreDao.getAllMatchScores(
|
final match2Scores = await database.scoreEntryDao.getAllMatchScores(
|
||||||
matchId: testMatch2.id,
|
matchId: testMatch2.id,
|
||||||
);
|
);
|
||||||
expect(match2Scores.length, 1);
|
expect(match2Scores.length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('deleteAllScoresForPlayerInMatch() works correctly', () async {
|
test('deleteAllScoresForPlayerInMatch() works correctly', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 2, score: 15, change: 5),
|
entry: ScoreEntry(roundNumber: 2, score: 15, change: 5),
|
||||||
);
|
);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer2.id,
|
playerId: testPlayer2.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 6, change: 6),
|
entry: ScoreEntry(roundNumber: 1, score: 6, change: 6),
|
||||||
);
|
);
|
||||||
|
|
||||||
final deleted = await database.scoreDao.deleteAllScoresForPlayerInMatch(
|
final deleted = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.deleteAllScoresForPlayerInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
|
|
||||||
expect(deleted, true);
|
expect(deleted, true);
|
||||||
|
|
||||||
final player1Scores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final player1Scores = await database.scoreEntryDao
|
||||||
playerId: testPlayer1.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer1.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(player1Scores.length, 0);
|
expect(player1Scores.length, 0);
|
||||||
|
|
||||||
final player2Scores = await database.scoreDao.getAllPlayerScoresInMatch(
|
final player2Scores = await database.scoreEntryDao
|
||||||
playerId: testPlayer2.id,
|
.getAllPlayerScoresInMatch(
|
||||||
matchId: testMatch1.id,
|
playerId: testPlayer2.id,
|
||||||
);
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(player2Scores.length, 1);
|
expect(player2Scores.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Score Aggregations & Edge Cases', () {
|
group('Score Aggregations & Edge Cases', () {
|
||||||
test('getLatestRoundNumber()', () async {
|
test('getLatestRoundNumber()', () async {
|
||||||
var latestRound = await database.scoreDao.getLatestRoundNumber(
|
var latestRound = await database.scoreEntryDao.getLatestRoundNumber(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(latestRound, isNull);
|
expect(latestRound, isNull);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
|
|
||||||
latestRound = await database.scoreDao.getLatestRoundNumber(
|
latestRound = await database.scoreEntryDao.getLatestRoundNumber(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(latestRound, 1);
|
expect(latestRound, 1);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 5, score: 50, change: 40),
|
entry: ScoreEntry(roundNumber: 5, score: 50, change: 40),
|
||||||
);
|
);
|
||||||
|
|
||||||
latestRound = await database.scoreDao.getLatestRoundNumber(
|
latestRound = await database.scoreEntryDao.getLatestRoundNumber(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(latestRound, 5);
|
expect(latestRound, 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getLatestRoundNumber() with non-consecutive rounds', () async {
|
test('getLatestRoundNumber() with non-consecutive rounds', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 5, score: 50, change: 40),
|
entry: ScoreEntry(roundNumber: 5, score: 50, change: 40),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 3, score: 30, change: 20),
|
entry: ScoreEntry(roundNumber: 3, score: 30, change: 20),
|
||||||
);
|
);
|
||||||
|
|
||||||
final latestRound = await database.scoreDao.getLatestRoundNumber(
|
final latestRound = await database.scoreEntryDao.getLatestRoundNumber(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -525,29 +532,29 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getTotalScoreForPlayer()', () async {
|
test('getTotalScoreForPlayer()', () async {
|
||||||
var totalScore = await database.scoreDao.getTotalScoreForPlayer(
|
var totalScore = await database.scoreEntryDao.getTotalScoreForPlayer(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(totalScore, 0);
|
expect(totalScore, 0);
|
||||||
|
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 2, score: 25, change: 15),
|
entry: ScoreEntry(roundNumber: 2, score: 25, change: 15),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 3, score: 40, change: 15),
|
entry: ScoreEntry(roundNumber: 3, score: 40, change: 15),
|
||||||
);
|
);
|
||||||
|
|
||||||
totalScore = await database.scoreDao.getTotalScoreForPlayer(
|
totalScore = await database.scoreEntryDao.getTotalScoreForPlayer(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
@@ -555,23 +562,23 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getTotalScoreForPlayer() ignores round score', () async {
|
test('getTotalScoreForPlayer() ignores round score', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 2, score: 25, change: 25),
|
entry: ScoreEntry(roundNumber: 2, score: 25, change: 25),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 25, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 25, change: 10),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 3, score: 25, change: 25),
|
entry: ScoreEntry(roundNumber: 3, score: 25, change: 25),
|
||||||
);
|
);
|
||||||
|
|
||||||
final totalScore = await database.scoreDao.getTotalScoreForPlayer(
|
final totalScore = await database.scoreEntryDao.getTotalScoreForPlayer(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
@@ -581,18 +588,18 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Adding the same score twice replaces the existing one', () async {
|
test('Adding the same score twice replaces the existing one', () async {
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
entry: ScoreEntry(roundNumber: 1, score: 10, change: 10),
|
||||||
);
|
);
|
||||||
await database.scoreDao.addScore(
|
await database.scoreEntryDao.addScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
entry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
entry: ScoreEntry(roundNumber: 1, score: 20, change: 20),
|
||||||
);
|
);
|
||||||
|
|
||||||
final score = await database.scoreDao.getScore(
|
final score = await database.scoreEntryDao.getScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
roundNumber: 1,
|
roundNumber: 1,
|
||||||
@@ -606,100 +613,116 @@ void main() {
|
|||||||
|
|
||||||
group('Handling Winner', () {
|
group('Handling Winner', () {
|
||||||
test('hasWinner() works correctly', () async {
|
test('hasWinner() works correctly', () async {
|
||||||
var hasWinner = await database.scoreDao.hasWinner(
|
var hasWinner = await database.scoreEntryDao.hasWinner(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(hasWinner, false);
|
expect(hasWinner, false);
|
||||||
|
|
||||||
await database.scoreDao.setWinner(
|
await database.scoreEntryDao.setWinner(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
hasWinner = await database.scoreDao.hasWinner(matchId: testMatch1.id);
|
hasWinner = await database.scoreEntryDao.hasWinner(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(hasWinner, true);
|
expect(hasWinner, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getWinnersForMatch() returns correct winner', () async {
|
test('getWinnersForMatch() returns correct winner', () async {
|
||||||
var winner = await database.scoreDao.getWinner(matchId: testMatch1.id);
|
var winner = await database.scoreEntryDao.getWinner(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(winner, isNull);
|
expect(winner, isNull);
|
||||||
|
|
||||||
await database.scoreDao.setWinner(
|
await database.scoreEntryDao.setWinner(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
winner = await database.scoreDao.getWinner(matchId: testMatch1.id);
|
winner = await database.scoreEntryDao.getWinner(matchId: testMatch1.id);
|
||||||
|
|
||||||
expect(winner, isNotNull);
|
expect(winner, isNotNull);
|
||||||
expect(winner!.id, testPlayer1.id);
|
expect(winner!.id, testPlayer1.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('removeWinner() works correctly', () async {
|
test('removeWinner() works correctly', () async {
|
||||||
var removed = await database.scoreDao.removeWinner(
|
var removed = await database.scoreEntryDao.removeWinner(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(removed, false);
|
expect(removed, false);
|
||||||
|
|
||||||
await database.scoreDao.setWinner(
|
await database.scoreEntryDao.setWinner(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
removed = await database.scoreDao.removeWinner(matchId: testMatch1.id);
|
removed = await database.scoreEntryDao.removeWinner(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(removed, true);
|
expect(removed, true);
|
||||||
|
|
||||||
var winner = await database.scoreDao.getWinner(matchId: testMatch1.id);
|
var winner = await database.scoreEntryDao.getWinner(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(winner, isNull);
|
expect(winner, isNull);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Handling Looser', () {
|
group('Handling Looser', () {
|
||||||
test('hasLooser() works correctly', () async {
|
test('hasLooser() works correctly', () async {
|
||||||
var hasLooser = await database.scoreDao.hasLooser(
|
var hasLooser = await database.scoreEntryDao.hasLooser(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(hasLooser, false);
|
expect(hasLooser, false);
|
||||||
|
|
||||||
await database.scoreDao.setLooser(
|
await database.scoreEntryDao.setLooser(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
hasLooser = await database.scoreDao.hasLooser(matchId: testMatch1.id);
|
hasLooser = await database.scoreEntryDao.hasLooser(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(hasLooser, true);
|
expect(hasLooser, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getLooser() returns correct winner', () async {
|
test('getLooser() returns correct winner', () async {
|
||||||
var looser = await database.scoreDao.getLooser(matchId: testMatch1.id);
|
var looser = await database.scoreEntryDao.getLooser(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(looser, isNull);
|
expect(looser, isNull);
|
||||||
|
|
||||||
await database.scoreDao.setLooser(
|
await database.scoreEntryDao.setLooser(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
looser = await database.scoreDao.getLooser(matchId: testMatch1.id);
|
looser = await database.scoreEntryDao.getLooser(matchId: testMatch1.id);
|
||||||
|
|
||||||
expect(looser, isNotNull);
|
expect(looser, isNotNull);
|
||||||
expect(looser!.id, testPlayer1.id);
|
expect(looser!.id, testPlayer1.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('removeLooser() works correctly', () async {
|
test('removeLooser() works correctly', () async {
|
||||||
var removed = await database.scoreDao.removeLooser(
|
var removed = await database.scoreEntryDao.removeLooser(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
expect(removed, false);
|
expect(removed, false);
|
||||||
|
|
||||||
await database.scoreDao.setLooser(
|
await database.scoreEntryDao.setLooser(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
removed = await database.scoreDao.removeLooser(matchId: testMatch1.id);
|
removed = await database.scoreEntryDao.removeLooser(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(removed, true);
|
expect(removed, true);
|
||||||
|
|
||||||
var looser = await database.scoreDao.getLooser(matchId: testMatch1.id);
|
var looser = await database.scoreEntryDao.getLooser(
|
||||||
|
matchId: testMatch1.id,
|
||||||
|
);
|
||||||
expect(looser, isNull);
|
expect(looser, isNull);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -588,6 +588,18 @@ void main() {
|
|||||||
expect(games[0].ruleset, testGame.ruleset);
|
expect(games[0].ruleset, testGame.ruleset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseGamesFromJson() empty list', () {
|
||||||
|
final jsonMap = {'games': []};
|
||||||
|
final games = DataTransferService.parseGamesFromJson(jsonMap);
|
||||||
|
expect(games, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseGamesFromJson() missing key', () {
|
||||||
|
final jsonMap = <String, dynamic>{};
|
||||||
|
final games = DataTransferService.parseGamesFromJson(jsonMap);
|
||||||
|
expect(games, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
test('parseGroupsFromJson()', () {
|
test('parseGroupsFromJson()', () {
|
||||||
final playerById = {
|
final playerById = {
|
||||||
testPlayer1.id: testPlayer1,
|
testPlayer1.id: testPlayer1,
|
||||||
@@ -619,6 +631,18 @@ void main() {
|
|||||||
expect(groups[0].members[1].id, testPlayer2.id);
|
expect(groups[0].members[1].id, testPlayer2.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseGroupsFromJson() empty list', () {
|
||||||
|
final jsonMap = {'groups': []};
|
||||||
|
final groups = DataTransferService.parseGroupsFromJson(jsonMap, {});
|
||||||
|
expect(groups, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseGroupsFromJson() missing key', () {
|
||||||
|
final jsonMap = <String, dynamic>{};
|
||||||
|
final groups = DataTransferService.parseGroupsFromJson(jsonMap, {});
|
||||||
|
expect(groups, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
test('parseGroupsFromJson() ignores invalid player ids', () {
|
test('parseGroupsFromJson() ignores invalid player ids', () {
|
||||||
final playerById = {testPlayer1.id: testPlayer1};
|
final playerById = {testPlayer1.id: testPlayer1};
|
||||||
|
|
||||||
@@ -670,6 +694,18 @@ void main() {
|
|||||||
expect(teams[0].members[0].id, testPlayer1.id);
|
expect(teams[0].members[0].id, testPlayer1.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseTeamsFromJson() empty list', () {
|
||||||
|
final jsonMap = {'teams': []};
|
||||||
|
final teams = DataTransferService.parseTeamsFromJson(jsonMap, {});
|
||||||
|
expect(teams, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseTeamsFromJson() missing key', () {
|
||||||
|
final jsonMap = <String, dynamic>{};
|
||||||
|
final teams = DataTransferService.parseTeamsFromJson(jsonMap, {});
|
||||||
|
expect(teams, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
test('parseMatchesFromJson()', () {
|
test('parseMatchesFromJson()', () {
|
||||||
final playerById = {
|
final playerById = {
|
||||||
testPlayer1.id: testPlayer1,
|
testPlayer1.id: testPlayer1,
|
||||||
@@ -707,6 +743,28 @@ void main() {
|
|||||||
expect(matches[0].players.length, 2);
|
expect(matches[0].players.length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parseMatchesFromJson() empty list', () {
|
||||||
|
final jsonMap = {'teams': []};
|
||||||
|
final matches = DataTransferService.parseMatchesFromJson(
|
||||||
|
jsonMap,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
expect(matches, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseMatchesFromJson() missing key', () {
|
||||||
|
final jsonMap = <String, dynamic>{};
|
||||||
|
final matches = DataTransferService.parseMatchesFromJson(
|
||||||
|
jsonMap,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
expect(matches, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
test('parseMatchesFromJson() creates unknown game for missing game', () {
|
test('parseMatchesFromJson() creates unknown game for missing game', () {
|
||||||
final playerById = {testPlayer1.id: testPlayer1};
|
final playerById = {testPlayer1.id: testPlayer1};
|
||||||
final gameById = <String, Game>{};
|
final gameById = <String, Game>{};
|
||||||
|
|||||||
Reference in New Issue
Block a user