Neue Datenbank Struktur #156

Open
gelbeinhalb wants to merge 88 commits from feature/88-neue-datenbank-struktur into development
29 changed files with 227 additions and 197 deletions
Showing only changes of commit 1d352821fc - Show all commits

View File

@@ -17,13 +17,14 @@
"type": "string"
},
"description": {
"type": ["string", "null"]
"type": "string"
gelbeinhalb marked this conversation as resolved Outdated

Ich glaube es würde mehr Sinn machen, die description nicht nullable zu machen, sondern einfach durch leeren String zu ersetzen, weil wir uns dann viel null checken sparen

Ich glaube es würde mehr Sinn machen, die `description` nicht nullable zu machen, sondern einfach durch leeren String zu ersetzen, weil wir uns dann viel null checken sparen
}
},
"required": [
"id",
"createdAt",
"name"
"name",
gelbeinhalb marked this conversation as resolved Outdated

Bei required dann description hinzufügen

Bei `required` dann `description` hinzufügen
"description"
]
}
},
@@ -42,22 +43,26 @@
"type": "string"
},
"ruleset": {
gelbeinhalb marked this conversation as resolved Outdated

Ruleset hier auch nicht null, da Game immer ein Ruleset brauch.

Ruleset hier auch nicht null, da Game immer ein Ruleset brauch.
"type": ["string", "null"]
"type": "string"
},
"description": {
gelbeinhalb marked this conversation as resolved Outdated

Hier auch wieder description nicht null sondern empty

Hier auch wieder description nicht `null` sondern `empty`
"type": ["string", "null"]
"type": "string"
},
"color": {
gelbeinhalb marked this conversation as resolved Outdated

Warum machst du die color als integer aber die rulesets als string? Ich würde entweder beides als String oder beiden als int (bevorzugt), und beim retrieven dann als enum in den jeweiligen Klassen speichern.

Warum machst du die color als integer aber die rulesets als string? Ich würde entweder beides als `String` oder beiden als `int` (bevorzugt), und beim retrieven dann als `enum` in den jeweiligen Klassen speichern.

war ausversehen 😅😅

war ausversehen 😅😅
"type": ["integer", "null"]
"type": "string"
},
"icon": {
gelbeinhalb marked this conversation as resolved Outdated

Ich find Icons prinzipell keine schlechte Idee, aber finde sie dann eher bei z.B. Gruppen sinnvoller, weil was für Icons will man bei Games machen? Also bei Gruppen könnte man halt je nach sozialen Aspekten n icon setzen, bei Games fällt mir dazu nicht viel ein

Ich find Icons prinzipell keine schlechte Idee, aber finde sie dann eher bei z.B. Gruppen sinnvoller, weil was für Icons will man bei Games machen? Also bei Gruppen könnte man halt je nach sozialen Aspekten n icon setzen, bei Games fällt mir dazu nicht viel ein

hätte sowas gedacht wie poker karten oder andere icons für die games.
Gruppen icons würde ich auch adden

hätte sowas gedacht wie poker karten oder andere icons für die games. Gruppen icons würde ich auch adden

Das Problem ist, wenn du sagst Pokerkarten als Icon, musst du ja total viele Icons irgendwo her bekommen, die sehr speziell sind (Spielkarten, Brettspiel, etc ..), da würde ich dann vllt eher auf sowas wie emojis setzen und da ist die auswahl die thematisch dazu passt ja begrenzt. Aber sonst kann @sneeex nochmal sagen was er dazu denkt

Das Problem ist, wenn du sagst Pokerkarten als Icon, musst du ja total viele Icons irgendwo her bekommen, die sehr speziell sind (Spielkarten, Brettspiel, etc ..), da würde ich dann vllt eher auf sowas wie emojis setzen und da ist die auswahl die thematisch dazu passt ja begrenzt. Aber sonst kann @sneeex nochmal sagen was er dazu denkt

weiß nicht ob ich emojis geil finde, sehe aber das problem mit den icons

weiß nicht ob ich emojis geil finde, sehe aber das problem mit den icons

lass das sonst demnächst mal besprechen, was man für icons bräuchte

lass das sonst demnächst mal besprechen, was man für icons bräuchte
"type": ["string", "null"]
"type": "string"
}
},
"required": [
"id",
"createdAt",
"name"
"name",
"ruleset",
"description",
"color",
"icon"
]
}
},
@@ -76,7 +81,7 @@
"type": "string"
},
"description": {
"type": ["string", "null"]
"type": "string"
},
"memberIds": {
"type": "array",
@@ -89,6 +94,7 @@
"id",
"name",
"createdAt",
"description",
"memberIds"
]
}
@@ -137,10 +143,7 @@
"type": "string"
},
"gameId": {
flixcoo marked this conversation as resolved
Review

Was soll endedAt für einen Sinn haben? Also wozu brauche ich den Endzeitpunkt eines Spiels? Und vor allem wie lege ich den Fest? Wenn ich denn Winner setze?

Was soll `endedAt` für einen Sinn haben? Also wozu brauche ich den Endzeitpunkt eines Spiels? Und vor allem wie lege ich den Fest? Wenn ich denn Winner setze?
Review

Ich dachte, dass man den Zeitpunkt später braucht, wenn das Winner Attribut entfernt wird. Später soll das ja nur calculated werden basierend auf den scores der Spieler und nicht extra gespeichert werden. Dann braucht man ja einen Weg zu sagen, ob das Spiel fertig ist oder nicht. Einen endedAt Timestamp fand ich besser als einen einfachen finished boolean

Ich dachte, dass man den Zeitpunkt später braucht, wenn das Winner Attribut entfernt wird. Später soll das ja nur calculated werden basierend auf den scores der Spieler und nicht extra gespeichert werden. Dann braucht man ja einen Weg zu sagen, ob das Spiel fertig ist oder nicht. Einen `endedAt` Timestamp fand ich besser als einen einfachen `finished` boolean
Review

ah okay, ja fair

ah okay, ja fair
"anyOf": [
{"type": "string"},
{"type": "null"}
]
"type": "string"
},
"groupId": {
"anyOf": [
@@ -155,17 +158,16 @@
}
},
"notes": {
"anyOf": [
{"type": "string"},
{"type": "null"}
]
"type": "string"
}
},
"required": [
"id",
"name",
"createdAt",
"playerIds"
"gameId",
"playerIds",
"notes"
]
}
}

View File

@@ -56,7 +56,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
ruleset: game.ruleset.name,
description: game.description,
color: game.color,
icon: Value(game.icon),
icon: game.icon,
createdAt: game.createdAt,
),
mode: InsertMode.insertOrReplace,
@@ -82,7 +82,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
ruleset: game.ruleset.name,
description: game.description,
color: game.color,
icon: Value(game.icon),
icon: game.icon,
createdAt: game.createdAt,
),
)
@@ -153,7 +153,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
/// Updates the icon of the game with the given [gameId].
Future<void> updateGameIcon({
required String gameId,
required String? newIcon,
required String newIcon,
}) async {
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
GameTableCompanion(icon: Value(newIcon)),

View File

@@ -58,7 +58,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
GroupTableCompanion.insert(
id: group.id,
name: group.name,
description: Value(group.description),
description: group.description,
createdAt: group.createdAt,
),
mode: InsertMode.insertOrReplace,
@@ -108,7 +108,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
(group) => GroupTableCompanion.insert(
id: group.id,
name: group.name,
description: Value(group.description),
description: group.description,
createdAt: group.createdAt,
),
)
@@ -136,7 +136,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
(p) => PlayerTableCompanion.insert(
id: p.id,
name: p.name,
description: Value(p.description),
description: p.description,
createdAt: p.createdAt,
),
)
@@ -196,7 +196,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
Future<bool> updateGroupDescription({
required String groupId,
required String? newDescription,
required String newDescription,
}) async {
final rowsAffected =
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(

View File

@@ -36,7 +36,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
game: game,
group: group,
players: players,
notes: row.notes,
notes: row.notes ?? '',
createdAt: row.createdAt,
);
}),
@@ -66,7 +66,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
game: game,
group: group,
players: players,
notes: result.notes,
notes: result.notes ?? '',
createdAt: result.createdAt,
);
}
@@ -75,15 +75,11 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
/// This method assumes that the game and group (if any) are already present
/// in the database.
Future<void> addMatch({required Match match}) async {
if (match.game == null) {
throw ArgumentError('Match must have a game associated with it');
}
await db.transaction(() async {
await into(matchTable).insert(
MatchTableCompanion.insert(
id: match.id,
gameId: match.game!.id,
gameId: match.game.id,
groupId: Value(match.group?.id),
name: Value(match.name),
notes: Value(match.notes),
@@ -113,9 +109,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
// Add all games first (deduplicated)
final uniqueGames = <String, Game>{};
for (final match in matches) {
if (match.game != null) {
uniqueGames[match.game!.id] = match.game!;
}
uniqueGames[match.game.id] = match.game;
}
if (uniqueGames.isNotEmpty) {
@@ -130,7 +124,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
ruleset: game.ruleset.name,
description: game.description,
color: game.color,
icon: Value(game.icon),
icon: game.icon,
createdAt: game.createdAt,
),
)
@@ -150,7 +144,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
(match) => GroupTableCompanion.insert(
id: match.group!.id,
name: match.group!.name,
description: Value(match.group!.description),
description: match.group!.description,
createdAt: match.group!.createdAt,
),
)
@@ -164,11 +158,10 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
(b) => b.insertAll(
matchTable,
matches
.where((match) => match.game != null)
.map(
(match) => MatchTableCompanion.insert(
id: match.id,
gameId: match.game!.id,
gameId: match.game.id,
groupId: Value(match.group?.id),
name: Value(match.name),
notes: Value(match.notes),
@@ -205,7 +198,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
(p) => PlayerTableCompanion.insert(
id: p.id,
name: p.name,
description: Value(p.description),
description: p.description,
createdAt: p.createdAt,
),
)

View File

@@ -46,7 +46,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
PlayerTableCompanion.insert(
id: player.id,
name: player.name,
description: Value(player.description),
description: player.description,
createdAt: player.createdAt,
),
mode: InsertMode.insertOrReplace,
@@ -70,7 +70,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
(player) => PlayerTableCompanion.insert(
id: player.id,
name: player.name,
description: Value(player.description),
description: player.description,
createdAt: player.createdAt,
),
)

View File

@@ -34,9 +34,9 @@ class $PlayerTableTable extends PlayerTable
late final GeneratedColumn<String> description = GeneratedColumn<String>(
'description',
aliasedName,
true,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
requiredDuringInsert: true,
);
static const VerificationMeta _createdAtMeta = const VerificationMeta(
'createdAt',
@@ -84,6 +84,8 @@ class $PlayerTableTable extends PlayerTable
_descriptionMeta,
),
);
} else if (isInserting) {
context.missing(_descriptionMeta);
}
if (data.containsKey('created_at')) {
context.handle(
@@ -113,7 +115,7 @@ class $PlayerTableTable extends PlayerTable
description: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}description'],
),
)!,
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
@@ -130,12 +132,12 @@ class $PlayerTableTable extends PlayerTable
class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
final String id;
final String name;
final String? description;
final String description;
final DateTime createdAt;
const PlayerTableData({
required this.id,
required this.name,
this.description,
required this.description,
required this.createdAt,
});
@override
@@ -143,9 +145,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
final map = <String, Expression>{};
map['id'] = Variable<String>(id);
map['name'] = Variable<String>(name);
if (!nullToAbsent || description != null) {
map['description'] = Variable<String>(description);
}
map['created_at'] = Variable<DateTime>(createdAt);
return map;
}
@@ -154,9 +154,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
return PlayerTableCompanion(
id: Value(id),
name: Value(name),
description: description == null && nullToAbsent
? const Value.absent()
: Value(description),
description: Value(description),
createdAt: Value(createdAt),
);
}
@@ -169,7 +167,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
return PlayerTableData(
id: serializer.fromJson<String>(json['id']),
name: serializer.fromJson<String>(json['name']),
description: serializer.fromJson<String?>(json['description']),
description: serializer.fromJson<String>(json['description']),
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
);
}
@@ -179,7 +177,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
return <String, dynamic>{
'id': serializer.toJson<String>(id),
'name': serializer.toJson<String>(name),
'description': serializer.toJson<String?>(description),
'description': serializer.toJson<String>(description),
'createdAt': serializer.toJson<DateTime>(createdAt),
};
}
@@ -187,12 +185,12 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
PlayerTableData copyWith({
String? id,
String? name,
Value<String?> description = const Value.absent(),
String? description,
DateTime? createdAt,
}) => PlayerTableData(
id: id ?? this.id,
name: name ?? this.name,
description: description.present ? description.value : this.description,
description: description ?? this.description,
createdAt: createdAt ?? this.createdAt,
);
PlayerTableData copyWithCompanion(PlayerTableCompanion data) {
@@ -232,7 +230,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
final Value<String> id;
final Value<String> name;
final Value<String?> description;
final Value<String> description;
final Value<DateTime> createdAt;
final Value<int> rowid;
const PlayerTableCompanion({
@@ -245,11 +243,12 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
PlayerTableCompanion.insert({
required String id,
required String name,
this.description = const Value.absent(),
required String description,
required DateTime createdAt,
this.rowid = const Value.absent(),
}) : id = Value(id),
name = Value(name),
description = Value(description),
createdAt = Value(createdAt);
static Insertable<PlayerTableData> custom({
Expression<String>? id,
@@ -270,7 +269,7 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
PlayerTableCompanion copyWith({
Value<String>? id,
Value<String>? name,
Value<String?>? description,
Value<String>? description,
Value<DateTime>? createdAt,
Value<int>? rowid,
}) {
@@ -348,9 +347,9 @@ class $GroupTableTable extends GroupTable
late final GeneratedColumn<String> description = GeneratedColumn<String>(
'description',
aliasedName,
true,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
requiredDuringInsert: true,
);
static const VerificationMeta _createdAtMeta = const VerificationMeta(
'createdAt',
@@ -398,6 +397,8 @@ class $GroupTableTable extends GroupTable
_descriptionMeta,
),
);
} else if (isInserting) {
context.missing(_descriptionMeta);
}
if (data.containsKey('created_at')) {
context.handle(
@@ -427,7 +428,7 @@ class $GroupTableTable extends GroupTable
description: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}description'],
),
)!,
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
@@ -444,12 +445,12 @@ class $GroupTableTable extends GroupTable
class GroupTableData extends DataClass implements Insertable<GroupTableData> {
final String id;
final String name;
final String? description;
final String description;
final DateTime createdAt;
const GroupTableData({
required this.id,
required this.name,
this.description,
required this.description,
required this.createdAt,
});
@override
@@ -457,9 +458,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
final map = <String, Expression>{};
map['id'] = Variable<String>(id);
map['name'] = Variable<String>(name);
if (!nullToAbsent || description != null) {
map['description'] = Variable<String>(description);
}
map['created_at'] = Variable<DateTime>(createdAt);
return map;
}
@@ -468,9 +467,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
return GroupTableCompanion(
id: Value(id),
name: Value(name),
description: description == null && nullToAbsent
? const Value.absent()
: Value(description),
description: Value(description),
createdAt: Value(createdAt),
);
}
@@ -483,7 +480,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
return GroupTableData(
id: serializer.fromJson<String>(json['id']),
name: serializer.fromJson<String>(json['name']),
description: serializer.fromJson<String?>(json['description']),
description: serializer.fromJson<String>(json['description']),
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
);
}
@@ -493,7 +490,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
return <String, dynamic>{
'id': serializer.toJson<String>(id),
'name': serializer.toJson<String>(name),
'description': serializer.toJson<String?>(description),
'description': serializer.toJson<String>(description),
'createdAt': serializer.toJson<DateTime>(createdAt),
};
}
@@ -501,12 +498,12 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
GroupTableData copyWith({
String? id,
String? name,
Value<String?> description = const Value.absent(),
String? description,
DateTime? createdAt,
}) => GroupTableData(
id: id ?? this.id,
name: name ?? this.name,
description: description.present ? description.value : this.description,
description: description ?? this.description,
createdAt: createdAt ?? this.createdAt,
);
GroupTableData copyWithCompanion(GroupTableCompanion data) {
@@ -546,7 +543,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
final Value<String> id;
final Value<String> name;
final Value<String?> description;
final Value<String> description;
final Value<DateTime> createdAt;
final Value<int> rowid;
const GroupTableCompanion({
@@ -559,11 +556,12 @@ class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
GroupTableCompanion.insert({
required String id,
required String name,
this.description = const Value.absent(),
required String description,
required DateTime createdAt,
this.rowid = const Value.absent(),
}) : id = Value(id),
name = Value(name),
description = Value(description),
createdAt = Value(createdAt);
static Insertable<GroupTableData> custom({
Expression<String>? id,
@@ -584,7 +582,7 @@ class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
GroupTableCompanion copyWith({
Value<String>? id,
Value<String>? name,
Value<String?>? description,
Value<String>? description,
Value<DateTime>? createdAt,
Value<int>? rowid,
}) {
@@ -691,9 +689,9 @@ class $GameTableTable extends GameTable
late final GeneratedColumn<String> icon = GeneratedColumn<String>(
'icon',
aliasedName,
true,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
requiredDuringInsert: true,
);
static const VerificationMeta _createdAtMeta = const VerificationMeta(
'createdAt',
@@ -773,6 +771,8 @@ class $GameTableTable extends GameTable
_iconMeta,
icon.isAcceptableOrUnknown(data['icon']!, _iconMeta),
);
} else if (isInserting) {
context.missing(_iconMeta);
}
if (data.containsKey('created_at')) {
context.handle(
@@ -814,7 +814,7 @@ class $GameTableTable extends GameTable
icon: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}icon'],
),
)!,
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
@@ -834,7 +834,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
final String ruleset;
final String description;
final String color;
final String? icon;
final String icon;
final DateTime createdAt;
const GameTableData({
required this.id,
@@ -842,7 +842,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
required this.ruleset,
required this.description,
required this.color,
this.icon,
required this.icon,
required this.createdAt,
});
@override
@@ -853,9 +853,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
map['ruleset'] = Variable<String>(ruleset);
map['description'] = Variable<String>(description);
map['color'] = Variable<String>(color);
if (!nullToAbsent || icon != null) {
map['icon'] = Variable<String>(icon);
}
map['created_at'] = Variable<DateTime>(createdAt);
return map;
}
@@ -867,7 +865,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
ruleset: Value(ruleset),
description: Value(description),
color: Value(color),
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
icon: Value(icon),
createdAt: Value(createdAt),
);
}
@@ -883,7 +881,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
ruleset: serializer.fromJson<String>(json['ruleset']),
description: serializer.fromJson<String>(json['description']),
color: serializer.fromJson<String>(json['color']),
icon: serializer.fromJson<String?>(json['icon']),
icon: serializer.fromJson<String>(json['icon']),
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
);
}
@@ -896,7 +894,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
'ruleset': serializer.toJson<String>(ruleset),
'description': serializer.toJson<String>(description),
'color': serializer.toJson<String>(color),
'icon': serializer.toJson<String?>(icon),
'icon': serializer.toJson<String>(icon),
'createdAt': serializer.toJson<DateTime>(createdAt),
};
}
@@ -907,7 +905,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
String? ruleset,
String? description,
String? color,
Value<String?> icon = const Value.absent(),
String? icon,
DateTime? createdAt,
}) => GameTableData(
id: id ?? this.id,
@@ -915,7 +913,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
ruleset: ruleset ?? this.ruleset,
description: description ?? this.description,
color: color ?? this.color,
icon: icon.present ? icon.value : this.icon,
icon: icon ?? this.icon,
createdAt: createdAt ?? this.createdAt,
);
GameTableData copyWithCompanion(GameTableCompanion data) {
@@ -968,7 +966,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
final Value<String> ruleset;
final Value<String> description;
final Value<String> color;
final Value<String?> icon;
final Value<String> icon;
final Value<DateTime> createdAt;
final Value<int> rowid;
const GameTableCompanion({
@@ -987,7 +985,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
required String ruleset,
required String description,
required String color,
this.icon = const Value.absent(),
required String icon,
required DateTime createdAt,
this.rowid = const Value.absent(),
}) : id = Value(id),
@@ -995,6 +993,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
ruleset = Value(ruleset),
description = Value(description),
color = Value(color),
icon = Value(icon),
createdAt = Value(createdAt);
static Insertable<GameTableData> custom({
Expression<String>? id,
@@ -1024,7 +1023,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
Value<String>? ruleset,
Value<String>? description,
Value<String>? color,
Value<String?>? icon,
Value<String>? icon,
Value<DateTime>? createdAt,
Value<int>? rowid,
}) {
@@ -2783,7 +2782,7 @@ typedef $$PlayerTableTableCreateCompanionBuilder =
PlayerTableCompanion Function({
required String id,
required String name,
Value<String?> description,
required String description,
required DateTime createdAt,
Value<int> rowid,
});
@@ -2791,7 +2790,7 @@ typedef $$PlayerTableTableUpdateCompanionBuilder =
PlayerTableCompanion Function({
Value<String> id,
Value<String> name,
Value<String?> description,
Value<String> description,
Value<DateTime> createdAt,
Value<int> rowid,
});
@@ -3133,7 +3132,7 @@ class $$PlayerTableTableTableManager
({
Value<String> id = const Value.absent(),
Value<String> name = const Value.absent(),
Value<String?> description = const Value.absent(),
Value<String> description = const Value.absent(),
Value<DateTime> createdAt = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => PlayerTableCompanion(
@@ -3147,7 +3146,7 @@ class $$PlayerTableTableTableManager
({
required String id,
required String name,
Value<String?> description = const Value.absent(),
required String description,
required DateTime createdAt,
Value<int> rowid = const Value.absent(),
}) => PlayerTableCompanion.insert(
@@ -3274,7 +3273,7 @@ typedef $$GroupTableTableCreateCompanionBuilder =
GroupTableCompanion Function({
required String id,
required String name,
Value<String?> description,
required String description,
required DateTime createdAt,
Value<int> rowid,
});
@@ -3282,7 +3281,7 @@ typedef $$GroupTableTableUpdateCompanionBuilder =
GroupTableCompanion Function({
Value<String> id,
Value<String> name,
Value<String?> description,
Value<String> description,
Value<DateTime> createdAt,
Value<int> rowid,
});
@@ -3550,7 +3549,7 @@ class $$GroupTableTableTableManager
({
Value<String> id = const Value.absent(),
Value<String> name = const Value.absent(),
Value<String?> description = const Value.absent(),
Value<String> description = const Value.absent(),
Value<DateTime> createdAt = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => GroupTableCompanion(
@@ -3564,7 +3563,7 @@ class $$GroupTableTableTableManager
({
required String id,
required String name,
Value<String?> description = const Value.absent(),
required String description,
required DateTime createdAt,
Value<int> rowid = const Value.absent(),
}) => GroupTableCompanion.insert(
@@ -3664,7 +3663,7 @@ typedef $$GameTableTableCreateCompanionBuilder =
required String ruleset,
required String description,
required String color,
Value<String?> icon,
required String icon,
required DateTime createdAt,
Value<int> rowid,
});
@@ -3675,7 +3674,7 @@ typedef $$GameTableTableUpdateCompanionBuilder =
Value<String> ruleset,
Value<String> description,
Value<String> color,
Value<String?> icon,
Value<String> icon,
Value<DateTime> createdAt,
Value<int> rowid,
});
@@ -3909,7 +3908,7 @@ class $$GameTableTableTableManager
Value<String> ruleset = const Value.absent(),
Value<String> description = const Value.absent(),
Value<String> color = const Value.absent(),
Value<String?> icon = const Value.absent(),
Value<String> icon = const Value.absent(),
Value<DateTime> createdAt = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) => GameTableCompanion(
@@ -3929,7 +3928,7 @@ class $$GameTableTableTableManager
required String ruleset,
required String description,
required String color,
Value<String?> icon = const Value.absent(),
required String icon,
required DateTime createdAt,
Value<int> rowid = const Value.absent(),
}) => GameTableCompanion.insert(

View File

@@ -6,7 +6,7 @@ class GameTable extends Table {
TextColumn get ruleset => text()();
gelbeinhalb marked this conversation as resolved
Review

Gleiche anmerkung wie oben, würde ich über einen int lösen

Gleiche anmerkung wie oben, würde ich über einen `int` lösen
TextColumn get description => text()();
gelbeinhalb marked this conversation as resolved Outdated

Gleiches wie oben, nicht nullable machen sondern einfach als Standard n leeren String

Gleiches wie oben, nicht nullable machen sondern einfach als Standard n leeren String
TextColumn get color => text()();
TextColumn get icon => text().nullable()();
TextColumn get icon => text()();
DateTimeColumn get createdAt => dateTime()();
@override

View File

@@ -3,7 +3,7 @@ import 'package:drift/drift.dart';
class GroupTable extends Table {
TextColumn get id => text()();
TextColumn get name => text()();
TextColumn get description => text().nullable()();
TextColumn get description => text()();
gelbeinhalb marked this conversation as resolved Outdated

Hier auch wieder nicht nullable machen sondern als leeren String setzen

Hier auch wieder nicht nullable machen sondern als leeren String setzen
DateTimeColumn get createdAt => dateTime()();
@override

View File

@@ -3,7 +3,7 @@ import 'package:drift/drift.dart';
class PlayerTable extends Table {
TextColumn get id => text()();
TextColumn get name => text()();
TextColumn get description => text().nullable()();
TextColumn get description => text()();
gelbeinhalb marked this conversation as resolved Outdated

Hier auch nicht nullable sondern empty string

Hier auch nicht nullable sondern empty string
DateTimeColumn get createdAt => dateTime()();
@override

View File

@@ -9,7 +9,7 @@ class Game {
final Ruleset ruleset;
gelbeinhalb marked this conversation as resolved Outdated

Description als leeren string setzen, wenn nicht übergeben

Description als leeren string setzen, wenn nicht übergeben

warum findest du leeren string besser als nullable?

warum findest du leeren string besser als nullable?

Finde null sollte man nur dann verwenden, wenns halt nicht anders geht, wie z.B. bei objekten

Finde null sollte man nur dann verwenden, wenns halt nicht anders geht, wie z.B. bei objekten
final String description;
gelbeinhalb marked this conversation as resolved Outdated

Hier lieber enum, gerne auch mit einem Color.none

Hier lieber enum, gerne auch mit einem `Color.none`

warum aber nicht hex codes?

warum aber nicht hex codes?

oder willst du die farben vorgeben?

oder willst du die farben vorgeben?

Ja man könnte auch hexcodes machen. Würde die Farben so oder so vorgeben unabhängig davon wie man sie speichert

Ja man könnte auch hexcodes machen. Würde die Farben so oder so vorgeben unabhängig davon wie man sie speichert

würde enums maybe machen, weil man sonst im export einfach den hex code ändern könnte. Also idk ob das juckt aber 🤷‍♂️

würde enums maybe machen, weil man sonst im export einfach den hex code ändern könnte. Also idk ob das juckt aber 🤷‍♂️
final String color;
gelbeinhalb marked this conversation as resolved Outdated

Hier auch mit enum arbeiten?

Hier auch mit enum arbeiten?
final String? icon;
final String icon;
Game({
String? id,
@@ -18,7 +18,7 @@ class Game {
required this.ruleset,
required this.description,
Review

Description sollte nicht obligatorisch sein, sondern optional. Wenn nicht gesetzt soll es ein leerer String werden.

Description sollte nicht obligatorisch sein, sondern optional. Wenn nicht gesetzt soll es ein leerer String werden.
Review

Dachte man soll den als leeren String selber setzen müssen

Dachte man soll den als leeren String selber setzen müssen
Review

würde das lieber so machen, weil man ja sonst immer unnötig die description setzten muss

würde das lieber so machen, weil man ja sonst immer unnötig die description setzten muss
Review

finde auch optional

finde auch optional
required this.color,
this.icon,
required this.icon,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now();

View File

@@ -5,7 +5,7 @@ import 'package:uuid/uuid.dart';
class Group {
final String id;
final String name;
final String? description;
final String description;
gelbeinhalb marked this conversation as resolved Outdated

Nicht nullable sondern empty string

Nicht nullable sondern empty string
final DateTime createdAt;
final List<Player> members;
@@ -13,7 +13,7 @@ class Group {
String? id,
DateTime? createdAt,
required this.name,
this.description,
required this.description,
Review

Auch hier Beschreibung optional

Auch hier Beschreibung optional
Review

.

.
required this.members,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now();

View File

@@ -1,4 +1,5 @@
import 'package:clock/clock.dart';
import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/data/dto/game.dart';
import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/player.dart';
@@ -8,20 +9,20 @@ class Match {
final String id;
final DateTime createdAt;
final String name;
gelbeinhalb marked this conversation as resolved Outdated

Game nicht optional sondern required

Game nicht optional sondern required
final Game? game;
final Game game;
final Group? group;
gelbeinhalb marked this conversation as resolved Outdated

Spielerliste auch nicht optional

Spielerliste auch nicht optional
final List<Player>? players;
final String? notes;
final String notes;
Player? winner;
Review

Notes optional

Notes optional
Review

Dachte leerer String

Dachte leerer String
Review

s.o.

s.o.
Match({
String? id,
DateTime? createdAt,
required this.name,
this.game,
required this.game,
this.group,
this.players,
this.notes,
required this.notes,
this.winner,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now();
@@ -37,17 +38,17 @@ class Match {
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
name = json['name'],
game = null, // Populated during import via DataTransferService
game = Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), // Populated during import via DataTransferService
group = null, // Populated during import via DataTransferService
players = [], // Populated during import via DataTransferService
notes = json['notes'];
notes = json['notes'] ?? '';
/// Converts the Match instance to a JSON object using normalized format (ID references only).
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),
'name': name,
'gameId': game?.id,
'gameId': game.id,
'groupId': group?.id,
'playerIds': (players ?? []).map((player) => player.id).toList(),
'notes': notes,

View File

@@ -5,13 +5,13 @@ class Player {
final String id;
final DateTime createdAt;
final String name;
final String? description;
final String description;
gelbeinhalb marked this conversation as resolved Outdated

Leerer String statt nullable

Leerer String statt nullable
Player({
String? id,
DateTime? createdAt,
required this.name,
this.description,
required this.description,
Review

Description optional

Description optional
Review

Wieso? Ich dachte wir machen alles als leeren String?

Wieso? Ich dachte wir machen alles als leeren String?
Review

s.o.

s.o.
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now();

View File

@@ -84,6 +84,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
bool success = await db.groupDao.addGroup(
group: Group(
name: _groupNameController.text.trim(),
description: '',
members: selectedPlayers,
),
);

View File

@@ -35,7 +35,8 @@ class _GroupsViewState extends State<GroupsView> {
7,
Group(
name: 'Skeleton Group',
members: List.filled(6, Player(name: 'Skeleton Player')),
description: '',
members: List.filled(6, Player(name: 'Skeleton Player', description: '')),
),
);

View File

@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/game.dart';
import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart';
@@ -40,13 +42,16 @@ class _HomeViewState extends State<HomeView> {
2,
Match(
name: 'Skeleton Match',
game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
group: Group(
name: 'Skeleton Group',
description: '',
members: [
Player(name: 'Skeleton Player 1'),
Player(name: 'Skeleton Player 2'),
Player(name: 'Skeleton Player 1', description: ''),
Player(name: 'Skeleton Player 2', description: ''),
],
),
notes: '',
),
);
@@ -114,7 +119,7 @@ class _HomeViewState extends State<HomeView> {
MatchResultView(match: match),
),
);
await updatedWinnerinRecentMatches(match.id);
await updatedWinnerInRecentMatches(match.id);
},
),
)
@@ -214,7 +219,7 @@ class _HomeViewState extends State<HomeView> {
}
/// 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 winner = await db.matchDao.getWinner(matchId: matchId);
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);

View File

@@ -203,6 +203,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
description: selectedGame.$2,
ruleset: selectedGame.$3,
color: '0xFF000000',
icon: '',
);
} else {
// Use the selected game from the list
@@ -212,6 +213,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
description: selectedGame.$2,
ruleset: selectedGame.$3,
color: '0xFF000000',
icon: '',
);
}
// Add the game to the database if it doesn't exist
@@ -225,6 +227,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
game: gameToUse,
group: selectedGroup,
players: selectedPlayers,
notes: '',
);
await db.matchDao.addMatch(match: match);
if (context.mounted) {

View File

@@ -5,7 +5,9 @@ import 'package:fluttericon/rpg_awesome_icons.dart';
import 'package:game_tracker/core/adaptive_page_route.dart';
import 'package:game_tracker/core/constants.dart';
import 'package:game_tracker/core/custom_theme.dart';
import 'package:game_tracker/core/enums.dart';
import 'package:game_tracker/data/db/database.dart';
import 'package:game_tracker/data/dto/game.dart';
import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/match.dart';
import 'package:game_tracker/data/dto/player.dart';
@@ -36,12 +38,15 @@ class _MatchViewState extends State<MatchView> {
4,
Match(
name: 'Skeleton match name',
game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
group: Group(
name: 'Group name',
members: List.filled(5, Player(name: 'Player')),
description: '',
members: List.filled(5, Player(name: 'Player', description: '')),
),
winner: Player(name: 'Player'),
players: [Player(name: 'Player')],
winner: Player(name: 'Player', description: ''),
players: [Player(name: 'Player', description: '')],
notes: '',
),
);

View File

@@ -167,7 +167,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final playerId = winCounts[i].$1;
final player = players.firstWhere(
(p) => p.id == playerId,
orElse: () => Player(id: playerId, name: loc.not_available),
orElse: () => Player(id: playerId, name: loc.not_available, description: ''),
);
winCounts[i] = (player.name, winCounts[i].$2);
}
@@ -231,7 +231,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final playerId = matchCounts[i].$1;
final player = players.firstWhere(
(p) => p.id == playerId,
orElse: () => Player(id: playerId, name: loc.not_available),
orElse: () => Player(id: playerId, name: loc.not_available, description: ''),
);
matchCounts[i] = (player.name, matchCounts[i].$2);
}

View File

@@ -62,7 +62,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
/// Skeleton data used while loading players.
late final List<Player> skeletonData = List.filled(
7,
Player(name: 'Player 0'),
Player(name: 'Player 0', description: ''),
);
@override
@@ -260,7 +260,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
final loc = AppLocalizations.of(context);
final playerName = _searchBarController.text.trim();
final createdPlayer = Player(name: playerName);
final createdPlayer = Player(name: playerName, description: '');
final success = await db.playerDao.addPlayer(player: createdPlayer);
if (!context.mounted) return;

View File

@@ -61,7 +61,7 @@ class DataTransferService {
'id': m.id,
'name': m.name,
'createdAt': m.createdAt.toIso8601String(),
'gameId': m.game?.id,
'gameId': m.game.id,
'groupId': m.group?.id,
'playerIds': (m.players ?? []).map((p) => p.id).toList(),
'notes': m.notes,
@@ -160,7 +160,7 @@ class DataTransferService {
return Group(
id: map['id'] as String,
name: map['name'] as String,
description: map['description'] as String?,
description: map['description'] as String,
members: members,
createdAt: DateTime.parse(map['createdAt'] as String),
);
@@ -192,11 +192,11 @@ class DataTransferService {
final List<Match> importedMatches = matchesJson.map((m) {
final map = m as Map<String, dynamic>;
final String? gameId = map['gameId'] as String?;
final String gameId = map['gameId'] as String;
final String? groupId = map['groupId'] as String?;
final List<String> playerIds = (map['playerIds'] as List<dynamic>? ?? []).cast<String>();
final game = (gameId == null) ? null : gameById[gameId];
final game = gameById[gameId];
final group = (groupId == null) ? null : groupById[groupId];
final players = playerIds
.map((id) => playerById[id])
@@ -206,11 +206,11 @@ class DataTransferService {
return Match(
id: map['id'] as String,
name: map['name'] as String,
game: game,
game: game ?? Game(name: 'Unknown', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
group: group,
players: players.isNotEmpty ? players : null,
createdAt: DateTime.parse(map['createdAt'] as String),
notes: map['notes'] as String?,
notes: map['notes'] as String? ?? '',
);
}).toList();

View File

@@ -44,6 +44,7 @@ void main() {
ruleset: Ruleset.highestScore,
description: 'A board game about real estate',
color: '0xFF000000',
icon: '',
);
});
});
@@ -133,7 +134,7 @@ void main() {
// Verifies that a game with null optional fields can be added and retrieved.
test('addGame handles game with null optional fields', () async {
final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000');
final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000', icon: '');
final result = await database.gameDao.addGame(game: gameWithNulls);
expect(result, true);
@@ -374,19 +375,19 @@ void main() {
expect(updatedGame.icon, 'new_chess_icon');
});
// Verifies that updateGameIcon can set the icon to null.
test('updateGameIcon can set icon to null', () async {
// Verifies that updateGameIcon can update the icon.
test('updateGameIcon updates icon correctly', () async {
await database.gameDao.addGame(game: testGame1);
await database.gameDao.updateGameIcon(
gameId: testGame1.id,
newIcon: null,
newIcon: 'new_icon',
);
final updatedGame = await database.gameDao.getGameById(
gameId: testGame1.id,
);
expect(updatedGame.icon, isNull);
expect(updatedGame.icon, 'new_icon');
});
// Verifies that updateGameIcon does nothing when game doesn't exist.
@@ -460,6 +461,7 @@ void main() {
ruleset: Ruleset.multipleWinners,
description: 'Description with émojis 🎮🎲',
color: '0xFF000000',
icon: '',
);
await database.gameDao.addGame(game: specialGame);
@@ -498,6 +500,7 @@ void main() {
description: longString,
ruleset: Ruleset.multipleWinners,
color: '0xFF000000',
icon: '',
);
await database.gameDao.addGame(game: longGame);

View File

@@ -29,27 +29,31 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
testGroup1 = Group(
name: 'Test Group',
description: '',
members: [testPlayer1, testPlayer2, testPlayer3],
);
testGroup2 = Group(
id: 'gr2',
name: 'Second Group',
description: '',
members: [testPlayer2, testPlayer3, testPlayer4],
);
testGroup3 = Group(
id: 'gr2',
name: 'Second Group',
description: '',
members: [testPlayer2, testPlayer4],
);
testGroup4 = Group(
id: 'gr2',
name: 'Second Group',
description: '',
members: [testPlayer1, testPlayer2, testPlayer3, testPlayer4],
);
});
@@ -262,14 +266,14 @@ void main() {
final updated = await database.groupDao.updateGroupDescription(
groupId: groupWithDescription.id,
newDescription: null,
newDescription: 'Updated description',
);
expect(updated, true);
final result = await database.groupDao.getGroupById(
groupId: groupWithDescription.id,
);
expect(result.description, isNull);
expect(result.description, 'Updated description');
});
// Verifies that updateGroupDescription returns false for a non-existent group.
@@ -324,6 +328,7 @@ void main() {
test('Group with empty members list is stored correctly', () async {
final emptyGroup = Group(
name: 'Empty Group',
description: '',
members: [],
);
await database.groupDao.addGroup(group: emptyGroup);

View File

@@ -36,26 +36,29 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer5 = Player(name: 'Eve');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
testPlayer5 = Player(name: 'Eve', description: '');
testGroup1 = Group(
name: 'Test Group 2',
description: '',
members: [testPlayer1, testPlayer2, testPlayer3],
);
testGroup2 = Group(
name: 'Test Group 2',
description: '',
members: [testPlayer4, testPlayer5],
);
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
testMatch1 = Match(
name: 'First Test Match',
game: testGame,
group: testGroup1,
players: [testPlayer4, testPlayer5],
winner: testPlayer4,
notes: '',
);
testMatch2 = Match(
name: 'Second Test Match',
@@ -63,17 +66,20 @@ void main() {
group: testGroup2,
players: [testPlayer1, testPlayer2, testPlayer3],
winner: testPlayer2,
notes: '',
);
testMatchOnlyPlayers = Match(
name: 'Test Match with Players',
game: testGame,
players: [testPlayer1, testPlayer2, testPlayer3],
winner: testPlayer3,
notes: '',
);
testMatchOnlyGroup = Match(
name: 'Test Match with Group',
game: testGame,
group: testGroup2,
notes: '',
);
});
await database.playerDao.addPlayersAsList(

View File

@@ -26,12 +26,13 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
testGroup = Group(
name: 'Test Group',
description: '',
members: [testPlayer1, testPlayer2, testPlayer3],
);
});
@@ -186,7 +187,7 @@ void main() {
// Verifies that getPlayersOfGroup returns empty list for group with no members.
test('getPlayersOfGroup returns empty list for empty group', () async {
final emptyGroup = Group(name: 'Empty Group', members: []);
final emptyGroup = Group(name: 'Empty Group', description: '', members: []);
await database.groupDao.addGroup(group: emptyGroup);
final players = await database.playerGroupDao.getPlayersOfGroup(
@@ -230,7 +231,7 @@ void main() {
// Verifies that a player can be in multiple groups.
test('Player can be in multiple groups', () async {
final secondGroup = Group(name: 'Second Group', members: []);
final secondGroup = Group(name: 'Second Group', description: '', members: []);
await database.groupDao.addGroup(group: testGroup);
await database.groupDao.addGroup(group: secondGroup);
@@ -255,7 +256,7 @@ void main() {
// Verifies that removing player from one group doesn't affect other groups.
test('Removing player from one group does not affect other groups', () async {
final secondGroup = Group(name: 'Second Group', members: [testPlayer1]);
final secondGroup = Group(name: 'Second Group', description: '', members: [testPlayer1]);
await database.groupDao.addGroup(group: testGroup);
await database.groupDao.addGroup(group: secondGroup);

View File

@@ -37,26 +37,29 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer5 = Player(name: 'Eve');
testPlayer6 = Player(name: 'Frank');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
testPlayer5 = Player(name: 'Eve', description: '');
testPlayer6 = Player(name: 'Frank', description: '');
testGroup = Group(
name: 'Test Group',
description: '',
members: [testPlayer1, testPlayer2, testPlayer3],
);
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
testMatchOnlyGroup = Match(
name: 'Test Match with Group',
game: testGame,
group: testGroup,
notes: '',
);
testMatchOnlyPlayers = Match(
name: 'Test Match with Players',
game: testGame,
players: [testPlayer4, testPlayer5, testPlayer6],
notes: '',
);
testTeam1 = Team(
name: 'Team Alpha',
@@ -226,8 +229,8 @@ void main() {
'Adding the same player to separate matches works correctly',
() async {
final playersList = [testPlayer1, testPlayer2, testPlayer3];
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
await Future.wait([
database.matchDao.addMatch(match: match1),
@@ -760,8 +763,8 @@ void main() {
// Verifies that removePlayerFromMatch does not affect other matches.
test('removePlayerFromMatch does not affect other matches', () async {
final playersList = [testPlayer1, testPlayer2];
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
await Future.wait([
database.matchDao.addMatch(match: match1),
@@ -793,8 +796,8 @@ void main() {
// Verifies that updating scores for players in different matches are independent.
test('Player scores are independent across matches', () async {
final playersList = [testPlayer1];
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
await Future.wait([
database.matchDao.addMatch(match: match1),

View File

@@ -24,10 +24,10 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Test Player');
testPlayer2 = Player(name: 'Second Player');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer1 = Player(name: 'Test Player', description: '');
testPlayer2 = Player(name: 'Second Player', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
});
});
tearDown(() async {
@@ -265,7 +265,7 @@ void main() {
// Verifies that a player with special characters in name is stored correctly.
test('Player with special characters in name is stored correctly', () async {
final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~');
final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~', description: '');
await database.playerDao.addPlayer(player: specialPlayer);
@@ -293,14 +293,14 @@ void main() {
// Verifies that a player with null description is stored correctly.
test('Player with null description is stored correctly', () async {
final playerWithoutDescription = Player(name: 'No Description Player');
final playerWithoutDescription = Player(name: 'No Description Player', description: '');
await database.playerDao.addPlayer(player: playerWithoutDescription);
final fetchedPlayer = await database.playerDao.getPlayerById(
playerId: playerWithoutDescription.id,
);
expect(fetchedPlayer.description, isNull);
expect(fetchedPlayer.description, '');
});
// Verifies that multiple updates to the same player work correctly.
@@ -340,7 +340,7 @@ void main() {
// Verifies that a player with empty string name is stored correctly.
test('Player with empty string name is stored correctly', () async {
final emptyNamePlayer = Player(name: '');
final emptyNamePlayer = Player(name: '', description: '');
await database.playerDao.addPlayer(player: emptyNamePlayer);
@@ -353,7 +353,7 @@ void main() {
// Verifies that a player with very long name is stored correctly.
test('Player with very long name is stored correctly', () async {
final longName = 'A' * 1000;
final longNamePlayer = Player(name: longName);
final longNamePlayer = Player(name: longName, description: '');
await database.playerDao.addPlayer(player: longNamePlayer);

View File

@@ -29,19 +29,21 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
testMatch1 = Match(
name: 'Test Match 1',
game: testGame,
players: [testPlayer1, testPlayer2],
notes: '',
);
testMatch2 = Match(
name: 'Test Match 2',
game: testGame,
players: [testPlayer2, testPlayer3],
notes: '',
);
});

View File

@@ -33,10 +33,10 @@ void main() {
);
withClock(fakeClock, () {
testPlayer1 = Player(name: 'Alice');
testPlayer2 = Player(name: 'Bob');
testPlayer3 = Player(name: 'Charlie');
testPlayer4 = Player(name: 'Diana');
testPlayer1 = Player(name: 'Alice', description: '');
testPlayer2 = Player(name: 'Bob', description: '');
testPlayer3 = Player(name: 'Charlie', description: '');
testPlayer4 = Player(name: 'Diana', description: '');
testTeam1 = Team(
name: 'Team Alpha',
members: [testPlayer1, testPlayer2],
@@ -49,8 +49,8 @@ void main() {
name: 'Team Gamma',
members: [testPlayer1, testPlayer3],
);
testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000');
testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000');
testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000', icon: '');
testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000', icon: '');
});
await database.playerDao.addPlayersAsList(
@@ -344,8 +344,8 @@ void main() {
// Verifies that teams with overlapping members are independent.
test('Teams with overlapping members are independent', () async {
// Create two matches since player_match has primary key {playerId, matchId}
final match1 = Match(name: 'Match 1', game: testGame1);
final match2 = Match(name: 'Match 2', game: testGame2);
final match1 = Match(name: 'Match 1', game: testGame1, notes: '');
final match2 = Match(name: 'Match 2', game: testGame2, notes: '');
await database.matchDao.addMatch(match: match1);
await database.matchDao.addMatch(match: match2);