From 807ae61df7e6c4d7bf91fd854d42fbd903bd7cf1 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Sun, 24 May 2026 13:52:27 +0200 Subject: [PATCH] feat: basic database functionality --- lib/data/dao/statistic_dao.dart | 112 + lib/data/dao/statistic_dao.g.dart | 19 + lib/data/dao/statistic_game_dao.dart | 60 + lib/data/dao/statistic_game_dao.g.dart | 29 + lib/data/dao/statistic_group_dao.dart | 66 + lib/data/dao/statistic_group_dao.g.dart | 29 + lib/data/dao/statistic_scope_dao.dart | 55 + lib/data/dao/statistic_scope_dao.g.dart | 26 + lib/data/db/database.dart | 16 + lib/data/db/database.g.dart | 2842 ++++++++++++++++- lib/data/db/tables/statistic_game_table.dart | 13 + lib/data/db/tables/statistic_group_table.dart | 13 + lib/data/db/tables/statistic_scope_table.dart | 11 + lib/data/db/tables/statistic_table.dart | 10 + lib/data/models/statistic.dart | 10 +- .../create_statistic_view.dart | 4 +- .../statistics_view/statistics_view.dart | 127 +- pubspec.yaml | 2 +- test/db_tests/statistics/statistic_test.dart | 124 + 19 files changed, 3457 insertions(+), 111 deletions(-) create mode 100644 lib/data/dao/statistic_dao.dart create mode 100644 lib/data/dao/statistic_dao.g.dart create mode 100644 lib/data/dao/statistic_game_dao.dart create mode 100644 lib/data/dao/statistic_game_dao.g.dart create mode 100644 lib/data/dao/statistic_group_dao.dart create mode 100644 lib/data/dao/statistic_group_dao.g.dart create mode 100644 lib/data/dao/statistic_scope_dao.dart create mode 100644 lib/data/dao/statistic_scope_dao.g.dart create mode 100644 lib/data/db/tables/statistic_game_table.dart create mode 100644 lib/data/db/tables/statistic_group_table.dart create mode 100644 lib/data/db/tables/statistic_scope_table.dart create mode 100644 lib/data/db/tables/statistic_table.dart create mode 100644 test/db_tests/statistics/statistic_test.dart diff --git a/lib/data/dao/statistic_dao.dart b/lib/data/dao/statistic_dao.dart new file mode 100644 index 0000000..39904fc --- /dev/null +++ b/lib/data/dao/statistic_dao.dart @@ -0,0 +1,112 @@ +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +import 'package:tallee/core/enums.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/db/tables/statistic_table.dart'; +import 'package:tallee/data/models/statistic.dart'; + +part 'statistic_dao.g.dart'; + +@DriftAccessor(tables: [StatisticTable]) +class StatisticDao extends DatabaseAccessor + with _$StatisticDaoMixin { + StatisticDao(super.db); + + /* Create */ + + Future addStatistic({required Statistic statistic}) async { + await into(statisticTable).insert( + StatisticTableCompanion.insert( + id: statistic.id, + type: statistic.type.name, + timeframe: Value(statistic.timeframe?.name), + ), + mode: InsertMode.insertOrReplace, + ); + + await db.statisticScopeDao.addStatisticScopes( + statisticId: statistic.id, + scopes: statistic.scopes, + ); + + if (statistic.selectedGroups != null) { + await db.statisticGroupDao.addStatisticGroups( + statisticId: statistic.id, + groups: statistic.selectedGroups!, + ); + } + + if (statistic.selectedGames != null) { + await db.statisticGameDao.addStatisticGames( + statisticId: statistic.id, + games: statistic.selectedGames!, + ); + } + + return true; + } + + /* Read */ + + Future getStatisticById(String statisticId) async { + final query = select(statisticTable); + final row = await query.getSingleOrNull(); + if (row != null) { + final groups = await db.statisticGroupDao.getGroupsForStatistic(row.id); + final games = await db.statisticGameDao.getGamesForStatistic(row.id); + final scopes = await db.statisticScopeDao.getScopeForStatistic(row.id); + + return Statistic( + type: StatisticType.values.firstWhere((type) => type.name == row.type), + scopes: scopes, + id: row.id, + timeframe: Timeframe.values.firstWhereOrNull( + (t) => t.name == row.timeframe, + ), + selectedGroups: groups, + selectedGames: games, + ); + } + return null; + } + + /// Retrieves all statistics from the database, including their associated groups and games. + Future> getAllStatistics() async { + final query = select(statisticTable); + final rows = await query.get(); + return Future.wait( + rows.map((row) async { + final groups = await db.statisticGroupDao.getGroupsForStatistic(row.id); + final games = await db.statisticGameDao.getGamesForStatistic(row.id); + + return Statistic( + type: StatisticType.values.firstWhere( + (type) => type.name == row.type, + ), + scopes: [], + id: row.id, + timeframe: Timeframe.values.firstWhereOrNull( + (t) => t.name == row.timeframe, + ), + selectedGroups: groups, + selectedGames: games, + ); + }), + ); + } + + /* Delete */ + + Future deleteStatistic(String statisticId) async { + final rowsDeleted = await (delete( + statisticTable, + )..where((tbl) => tbl.id.equals(statisticId))).go(); + + return rowsDeleted > 0; + } + + Future deleteAllStatistics() async { + final rowsDeleted = await delete(statisticTable).go(); + return rowsDeleted > 0; + } +} diff --git a/lib/data/dao/statistic_dao.g.dart b/lib/data/dao/statistic_dao.g.dart new file mode 100644 index 0000000..0ce36e1 --- /dev/null +++ b/lib/data/dao/statistic_dao.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'statistic_dao.dart'; + +// ignore_for_file: type=lint +mixin _$StatisticDaoMixin on DatabaseAccessor { + $StatisticTableTable get statisticTable => attachedDatabase.statisticTable; + StatisticDaoManager get managers => StatisticDaoManager(this); +} + +class StatisticDaoManager { + final _$StatisticDaoMixin _db; + StatisticDaoManager(this._db); + $$StatisticTableTableTableManager get statisticTable => + $$StatisticTableTableTableManager( + _db.attachedDatabase, + _db.statisticTable, + ); +} diff --git a/lib/data/dao/statistic_game_dao.dart b/lib/data/dao/statistic_game_dao.dart new file mode 100644 index 0000000..ea7260f --- /dev/null +++ b/lib/data/dao/statistic_game_dao.dart @@ -0,0 +1,60 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/core/enums.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/db/tables/statistic_game_table.dart'; +import 'package:tallee/data/models/game.dart'; + +part 'statistic_game_dao.g.dart'; + +@DriftAccessor(tables: [StatisticGameTable]) +class StatisticGameDao extends DatabaseAccessor + with _$StatisticGameDaoMixin { + StatisticGameDao(super.db); + + /// Retrieves a list of games associated with a specific statistic. + Future> getGamesForStatistic(String statisticId) async { + final query = select(statisticGameTable).join([ + innerJoin(gameTable, gameTable.id.equalsExp(statisticGameTable.gameId)), + ])..where(statisticGameTable.statisticId.equals(statisticId)); + + final results = await query.map((row) => row.readTable(gameTable)).get(); + return results + .map( + (result) => Game( + id: result.id, + name: result.name, + ruleset: Ruleset.values.firstWhere((e) => e.name == result.ruleset), + description: result.description, + color: GameColor.values.firstWhere((e) => e.name == result.color), + icon: result.icon, + createdAt: result.createdAt, + ), + ) + .toList(); + } + + Future addStatisticGames({ + required String statisticId, + required List games, + }) { + final entries = games + .map( + (game) => StatisticGameTableCompanion.insert( + statisticId: statisticId, + gameId: game.id, + ), + ) + .toList(); + + return batch((batch) { + batch.insertAll( + statisticGameTable, + entries, + mode: InsertMode.insertOrReplace, + ); + }).then((_) => true).catchError((error) { + print('Error adding statistic games: $error'); + return false; + }); + } +} diff --git a/lib/data/dao/statistic_game_dao.g.dart b/lib/data/dao/statistic_game_dao.g.dart new file mode 100644 index 0000000..d6ee984 --- /dev/null +++ b/lib/data/dao/statistic_game_dao.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'statistic_game_dao.dart'; + +// ignore_for_file: type=lint +mixin _$StatisticGameDaoMixin on DatabaseAccessor { + $StatisticTableTable get statisticTable => attachedDatabase.statisticTable; + $GameTableTable get gameTable => attachedDatabase.gameTable; + $StatisticGameTableTable get statisticGameTable => + attachedDatabase.statisticGameTable; + StatisticGameDaoManager get managers => StatisticGameDaoManager(this); +} + +class StatisticGameDaoManager { + final _$StatisticGameDaoMixin _db; + StatisticGameDaoManager(this._db); + $$StatisticTableTableTableManager get statisticTable => + $$StatisticTableTableTableManager( + _db.attachedDatabase, + _db.statisticTable, + ); + $$GameTableTableTableManager get gameTable => + $$GameTableTableTableManager(_db.attachedDatabase, _db.gameTable); + $$StatisticGameTableTableTableManager get statisticGameTable => + $$StatisticGameTableTableTableManager( + _db.attachedDatabase, + _db.statisticGameTable, + ); +} diff --git a/lib/data/dao/statistic_group_dao.dart b/lib/data/dao/statistic_group_dao.dart new file mode 100644 index 0000000..9eb9397 --- /dev/null +++ b/lib/data/dao/statistic_group_dao.dart @@ -0,0 +1,66 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/db/tables/group_table.dart'; +import 'package:tallee/data/db/tables/statistic_group_table.dart'; +import 'package:tallee/data/models/group.dart'; + +part 'statistic_group_dao.g.dart'; + +@DriftAccessor(tables: [StatisticGroupTable, GroupTable]) +class StatisticGroupDao extends DatabaseAccessor + with _$StatisticGroupDaoMixin { + StatisticGroupDao(super.db); + + /// Retrieves a list of groups associated with a specific statistic. + Future> getGroupsForStatistic(String statisticId) async { + final query = select(statisticGroupTable).join([ + innerJoin( + groupTable, + groupTable.id.equalsExp(statisticGroupTable.groupId), + ), + ])..where(statisticGroupTable.statisticId.equals(statisticId)); + + final results = await query.map((row) => row.readTable(groupTable)).get(); + final groups = await Future.wait( + results.map((result) async { + final groupMembers = await db.playerGroupDao.getPlayersOfGroup( + groupId: result.id, + ); + return Group( + id: result.id, + createdAt: result.createdAt, + name: result.name, + description: result.description, + members: groupMembers, + ); + }), + ); + + return groups; + } + + Future addStatisticGroups({ + required String statisticId, + required List groups, + }) async { + final entries = groups + .map( + (group) => StatisticGroupTableCompanion.insert( + statisticId: statisticId, + groupId: group.id, + ), + ) + .toList(); + + return batch((batch) { + batch.insertAll( + statisticGroupTable, + entries, + mode: InsertMode.insertOrReplace, + ); + }).then((_) => true).catchError((error) { + print('Error adding statistic groups: $error'); + return false; + }); + } +} diff --git a/lib/data/dao/statistic_group_dao.g.dart b/lib/data/dao/statistic_group_dao.g.dart new file mode 100644 index 0000000..57a83c5 --- /dev/null +++ b/lib/data/dao/statistic_group_dao.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'statistic_group_dao.dart'; + +// ignore_for_file: type=lint +mixin _$StatisticGroupDaoMixin on DatabaseAccessor { + $StatisticTableTable get statisticTable => attachedDatabase.statisticTable; + $GroupTableTable get groupTable => attachedDatabase.groupTable; + $StatisticGroupTableTable get statisticGroupTable => + attachedDatabase.statisticGroupTable; + StatisticGroupDaoManager get managers => StatisticGroupDaoManager(this); +} + +class StatisticGroupDaoManager { + final _$StatisticGroupDaoMixin _db; + StatisticGroupDaoManager(this._db); + $$StatisticTableTableTableManager get statisticTable => + $$StatisticTableTableTableManager( + _db.attachedDatabase, + _db.statisticTable, + ); + $$GroupTableTableTableManager get groupTable => + $$GroupTableTableTableManager(_db.attachedDatabase, _db.groupTable); + $$StatisticGroupTableTableTableManager get statisticGroupTable => + $$StatisticGroupTableTableTableManager( + _db.attachedDatabase, + _db.statisticGroupTable, + ); +} diff --git a/lib/data/dao/statistic_scope_dao.dart b/lib/data/dao/statistic_scope_dao.dart new file mode 100644 index 0000000..2027acd --- /dev/null +++ b/lib/data/dao/statistic_scope_dao.dart @@ -0,0 +1,55 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/core/enums.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/db/tables/statistic_scope_table.dart'; + +part 'statistic_scope_dao.g.dart'; + +@DriftAccessor(tables: [StatisticScopeTable]) +class StatisticScopeDao extends DatabaseAccessor + with _$StatisticScopeDaoMixin { + StatisticScopeDao(super.db); + + /// Retrieves a list of statistic scopes associated with a specific statistic ID. + Future> getScopeForStatistic(String statisticId) async { + final query = select(statisticScopeTable) + ..where((tbl) => tbl.statisticId.equals(statisticId)); + + final results = await query.get(); + return results + .map( + (result) => StatisticScope.values.firstWhere( + (e) => e.name == result.scope, + orElse: () => throw Exception( + 'Invalid scope value: ${result.scope} for statistic ID: $statisticId', + ), + ), + ) + .toList(); + } + + Future addStatisticScopes({ + required String statisticId, + required List scopes, + }) async { + final entries = scopes + .map( + (scope) => StatisticScopeTableCompanion.insert( + statisticId: statisticId, + scope: scope.name, + ), + ) + .toList(); + + return batch((batch) { + batch.insertAll( + statisticScopeTable, + entries, + mode: InsertMode.insertOrReplace, + ); + }).then((_) => true).catchError((error) { + print('Error adding statistic scopes: $error'); + return false; + }); + } +} diff --git a/lib/data/dao/statistic_scope_dao.g.dart b/lib/data/dao/statistic_scope_dao.g.dart new file mode 100644 index 0000000..adaa171 --- /dev/null +++ b/lib/data/dao/statistic_scope_dao.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'statistic_scope_dao.dart'; + +// ignore_for_file: type=lint +mixin _$StatisticScopeDaoMixin on DatabaseAccessor { + $StatisticTableTable get statisticTable => attachedDatabase.statisticTable; + $StatisticScopeTableTable get statisticScopeTable => + attachedDatabase.statisticScopeTable; + StatisticScopeDaoManager get managers => StatisticScopeDaoManager(this); +} + +class StatisticScopeDaoManager { + final _$StatisticScopeDaoMixin _db; + StatisticScopeDaoManager(this._db); + $$StatisticTableTableTableManager get statisticTable => + $$StatisticTableTableTableManager( + _db.attachedDatabase, + _db.statisticTable, + ); + $$StatisticScopeTableTableTableManager get statisticScopeTable => + $$StatisticScopeTableTableTableManager( + _db.attachedDatabase, + _db.statisticScopeTable, + ); +} diff --git a/lib/data/db/database.dart b/lib/data/db/database.dart index a7e9c1d..792da0e 100644 --- a/lib/data/db/database.dart +++ b/lib/data/db/database.dart @@ -8,6 +8,10 @@ import 'package:tallee/data/dao/player_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/score_entry_dao.dart'; +import 'package:tallee/data/dao/statistic_dao.dart'; +import 'package:tallee/data/dao/statistic_game_dao.dart'; +import 'package:tallee/data/dao/statistic_group_dao.dart'; +import 'package:tallee/data/dao/statistic_scope_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/group_table.dart'; @@ -16,6 +20,10 @@ import 'package:tallee/data/db/tables/player_group_table.dart'; import 'package:tallee/data/db/tables/player_match_table.dart'; import 'package:tallee/data/db/tables/player_table.dart'; import 'package:tallee/data/db/tables/score_entry_table.dart'; +import 'package:tallee/data/db/tables/statistic_game_table.dart'; +import 'package:tallee/data/db/tables/statistic_group_table.dart'; +import 'package:tallee/data/db/tables/statistic_scope_table.dart'; +import 'package:tallee/data/db/tables/statistic_table.dart'; import 'package:tallee/data/db/tables/team_table.dart'; part 'database.g.dart'; @@ -30,6 +38,10 @@ part 'database.g.dart'; GameTable, TeamTable, ScoreEntryTable, + StatisticTable, + StatisticScopeTable, + StatisticGameTable, + StatisticGroupTable, ], daos: [ PlayerDao, @@ -40,6 +52,10 @@ part 'database.g.dart'; GameDao, ScoreEntryDao, TeamDao, + StatisticDao, + StatisticScopeDao, + StatisticGameDao, + StatisticGroupDao, ], ) class AppDatabase extends _$AppDatabase { diff --git a/lib/data/db/database.g.dart b/lib/data/db/database.g.dart index c8d0faa..489b890 100644 --- a/lib/data/db/database.g.dart +++ b/lib/data/db/database.g.dart @@ -2732,6 +2732,971 @@ class ScoreEntryTableCompanion extends UpdateCompanion { } } +class $StatisticTableTable extends StatisticTable + with TableInfo<$StatisticTableTable, StatisticTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $StatisticTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + @override + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _timeframeMeta = const VerificationMeta( + 'timeframe', + ); + @override + late final GeneratedColumn timeframe = GeneratedColumn( + 'timeframe', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + ); + @override + List get $columns => [id, type, timeframe]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'statistic_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('type')) { + context.handle( + _typeMeta, + type.isAcceptableOrUnknown(data['type']!, _typeMeta), + ); + } else if (isInserting) { + context.missing(_typeMeta); + } + if (data.containsKey('timeframe')) { + context.handle( + _timeframeMeta, + timeframe.isAcceptableOrUnknown(data['timeframe']!, _timeframeMeta), + ); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + StatisticTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StatisticTableData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + type: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}type'], + )!, + timeframe: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}timeframe'], + ), + ); + } + + @override + $StatisticTableTable createAlias(String alias) { + return $StatisticTableTable(attachedDatabase, alias); + } +} + +class StatisticTableData extends DataClass + implements Insertable { + final String id; + final String type; + final String? timeframe; + const StatisticTableData({ + required this.id, + required this.type, + this.timeframe, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['type'] = Variable(type); + if (!nullToAbsent || timeframe != null) { + map['timeframe'] = Variable(timeframe); + } + return map; + } + + StatisticTableCompanion toCompanion(bool nullToAbsent) { + return StatisticTableCompanion( + id: Value(id), + type: Value(type), + timeframe: timeframe == null && nullToAbsent + ? const Value.absent() + : Value(timeframe), + ); + } + + factory StatisticTableData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StatisticTableData( + id: serializer.fromJson(json['id']), + type: serializer.fromJson(json['type']), + timeframe: serializer.fromJson(json['timeframe']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'type': serializer.toJson(type), + 'timeframe': serializer.toJson(timeframe), + }; + } + + StatisticTableData copyWith({ + String? id, + String? type, + Value timeframe = const Value.absent(), + }) => StatisticTableData( + id: id ?? this.id, + type: type ?? this.type, + timeframe: timeframe.present ? timeframe.value : this.timeframe, + ); + StatisticTableData copyWithCompanion(StatisticTableCompanion data) { + return StatisticTableData( + id: data.id.present ? data.id.value : this.id, + type: data.type.present ? data.type.value : this.type, + timeframe: data.timeframe.present ? data.timeframe.value : this.timeframe, + ); + } + + @override + String toString() { + return (StringBuffer('StatisticTableData(') + ..write('id: $id, ') + ..write('type: $type, ') + ..write('timeframe: $timeframe') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, type, timeframe); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StatisticTableData && + other.id == this.id && + other.type == this.type && + other.timeframe == this.timeframe); +} + +class StatisticTableCompanion extends UpdateCompanion { + final Value id; + final Value type; + final Value timeframe; + final Value rowid; + const StatisticTableCompanion({ + this.id = const Value.absent(), + this.type = const Value.absent(), + this.timeframe = const Value.absent(), + this.rowid = const Value.absent(), + }); + StatisticTableCompanion.insert({ + required String id, + required String type, + this.timeframe = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + type = Value(type); + static Insertable custom({ + Expression? id, + Expression? type, + Expression? timeframe, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (type != null) 'type': type, + if (timeframe != null) 'timeframe': timeframe, + if (rowid != null) 'rowid': rowid, + }); + } + + StatisticTableCompanion copyWith({ + Value? id, + Value? type, + Value? timeframe, + Value? rowid, + }) { + return StatisticTableCompanion( + id: id ?? this.id, + type: type ?? this.type, + timeframe: timeframe ?? this.timeframe, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (timeframe.present) { + map['timeframe'] = Variable(timeframe.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StatisticTableCompanion(') + ..write('id: $id, ') + ..write('type: $type, ') + ..write('timeframe: $timeframe, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $StatisticScopeTableTable extends StatisticScopeTable + with TableInfo<$StatisticScopeTableTable, StatisticScopeTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $StatisticScopeTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _statisticIdMeta = const VerificationMeta( + 'statisticId', + ); + @override + late final GeneratedColumn statisticId = GeneratedColumn( + 'statistic_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES statistic_table (id) ON DELETE CASCADE', + ), + ); + static const VerificationMeta _scopeMeta = const VerificationMeta('scope'); + @override + late final GeneratedColumn scope = GeneratedColumn( + 'scope', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + @override + List get $columns => [statisticId, scope]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'statistic_scope_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('statistic_id')) { + context.handle( + _statisticIdMeta, + statisticId.isAcceptableOrUnknown( + data['statistic_id']!, + _statisticIdMeta, + ), + ); + } else if (isInserting) { + context.missing(_statisticIdMeta); + } + if (data.containsKey('scope')) { + context.handle( + _scopeMeta, + scope.isAcceptableOrUnknown(data['scope']!, _scopeMeta), + ); + } else if (isInserting) { + context.missing(_scopeMeta); + } + return context; + } + + @override + Set get $primaryKey => {statisticId, scope}; + @override + StatisticScopeTableData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StatisticScopeTableData( + statisticId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}statistic_id'], + )!, + scope: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}scope'], + )!, + ); + } + + @override + $StatisticScopeTableTable createAlias(String alias) { + return $StatisticScopeTableTable(attachedDatabase, alias); + } +} + +class StatisticScopeTableData extends DataClass + implements Insertable { + final String statisticId; + final String scope; + const StatisticScopeTableData({ + required this.statisticId, + required this.scope, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['statistic_id'] = Variable(statisticId); + map['scope'] = Variable(scope); + return map; + } + + StatisticScopeTableCompanion toCompanion(bool nullToAbsent) { + return StatisticScopeTableCompanion( + statisticId: Value(statisticId), + scope: Value(scope), + ); + } + + factory StatisticScopeTableData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StatisticScopeTableData( + statisticId: serializer.fromJson(json['statisticId']), + scope: serializer.fromJson(json['scope']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'statisticId': serializer.toJson(statisticId), + 'scope': serializer.toJson(scope), + }; + } + + StatisticScopeTableData copyWith({String? statisticId, String? scope}) => + StatisticScopeTableData( + statisticId: statisticId ?? this.statisticId, + scope: scope ?? this.scope, + ); + StatisticScopeTableData copyWithCompanion(StatisticScopeTableCompanion data) { + return StatisticScopeTableData( + statisticId: data.statisticId.present + ? data.statisticId.value + : this.statisticId, + scope: data.scope.present ? data.scope.value : this.scope, + ); + } + + @override + String toString() { + return (StringBuffer('StatisticScopeTableData(') + ..write('statisticId: $statisticId, ') + ..write('scope: $scope') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(statisticId, scope); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StatisticScopeTableData && + other.statisticId == this.statisticId && + other.scope == this.scope); +} + +class StatisticScopeTableCompanion + extends UpdateCompanion { + final Value statisticId; + final Value scope; + final Value rowid; + const StatisticScopeTableCompanion({ + this.statisticId = const Value.absent(), + this.scope = const Value.absent(), + this.rowid = const Value.absent(), + }); + StatisticScopeTableCompanion.insert({ + required String statisticId, + required String scope, + this.rowid = const Value.absent(), + }) : statisticId = Value(statisticId), + scope = Value(scope); + static Insertable custom({ + Expression? statisticId, + Expression? scope, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (statisticId != null) 'statistic_id': statisticId, + if (scope != null) 'scope': scope, + if (rowid != null) 'rowid': rowid, + }); + } + + StatisticScopeTableCompanion copyWith({ + Value? statisticId, + Value? scope, + Value? rowid, + }) { + return StatisticScopeTableCompanion( + statisticId: statisticId ?? this.statisticId, + scope: scope ?? this.scope, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (statisticId.present) { + map['statistic_id'] = Variable(statisticId.value); + } + if (scope.present) { + map['scope'] = Variable(scope.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StatisticScopeTableCompanion(') + ..write('statisticId: $statisticId, ') + ..write('scope: $scope, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $StatisticGameTableTable extends StatisticGameTable + with TableInfo<$StatisticGameTableTable, StatisticGameTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $StatisticGameTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _statisticIdMeta = const VerificationMeta( + 'statisticId', + ); + @override + late final GeneratedColumn statisticId = GeneratedColumn( + 'statistic_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES statistic_table (id) ON DELETE CASCADE', + ), + ); + static const VerificationMeta _gameIdMeta = const VerificationMeta('gameId'); + @override + late final GeneratedColumn gameId = GeneratedColumn( + 'game_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES game_table (id) ON DELETE CASCADE', + ), + ); + @override + List get $columns => [statisticId, gameId]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'statistic_game_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('statistic_id')) { + context.handle( + _statisticIdMeta, + statisticId.isAcceptableOrUnknown( + data['statistic_id']!, + _statisticIdMeta, + ), + ); + } else if (isInserting) { + context.missing(_statisticIdMeta); + } + if (data.containsKey('game_id')) { + context.handle( + _gameIdMeta, + gameId.isAcceptableOrUnknown(data['game_id']!, _gameIdMeta), + ); + } else if (isInserting) { + context.missing(_gameIdMeta); + } + return context; + } + + @override + Set get $primaryKey => {statisticId, gameId}; + @override + StatisticGameTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StatisticGameTableData( + statisticId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}statistic_id'], + )!, + gameId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}game_id'], + )!, + ); + } + + @override + $StatisticGameTableTable createAlias(String alias) { + return $StatisticGameTableTable(attachedDatabase, alias); + } +} + +class StatisticGameTableData extends DataClass + implements Insertable { + final String statisticId; + final String gameId; + const StatisticGameTableData({ + required this.statisticId, + required this.gameId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['statistic_id'] = Variable(statisticId); + map['game_id'] = Variable(gameId); + return map; + } + + StatisticGameTableCompanion toCompanion(bool nullToAbsent) { + return StatisticGameTableCompanion( + statisticId: Value(statisticId), + gameId: Value(gameId), + ); + } + + factory StatisticGameTableData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StatisticGameTableData( + statisticId: serializer.fromJson(json['statisticId']), + gameId: serializer.fromJson(json['gameId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'statisticId': serializer.toJson(statisticId), + 'gameId': serializer.toJson(gameId), + }; + } + + StatisticGameTableData copyWith({String? statisticId, String? gameId}) => + StatisticGameTableData( + statisticId: statisticId ?? this.statisticId, + gameId: gameId ?? this.gameId, + ); + StatisticGameTableData copyWithCompanion(StatisticGameTableCompanion data) { + return StatisticGameTableData( + statisticId: data.statisticId.present + ? data.statisticId.value + : this.statisticId, + gameId: data.gameId.present ? data.gameId.value : this.gameId, + ); + } + + @override + String toString() { + return (StringBuffer('StatisticGameTableData(') + ..write('statisticId: $statisticId, ') + ..write('gameId: $gameId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(statisticId, gameId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StatisticGameTableData && + other.statisticId == this.statisticId && + other.gameId == this.gameId); +} + +class StatisticGameTableCompanion + extends UpdateCompanion { + final Value statisticId; + final Value gameId; + final Value rowid; + const StatisticGameTableCompanion({ + this.statisticId = const Value.absent(), + this.gameId = const Value.absent(), + this.rowid = const Value.absent(), + }); + StatisticGameTableCompanion.insert({ + required String statisticId, + required String gameId, + this.rowid = const Value.absent(), + }) : statisticId = Value(statisticId), + gameId = Value(gameId); + static Insertable custom({ + Expression? statisticId, + Expression? gameId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (statisticId != null) 'statistic_id': statisticId, + if (gameId != null) 'game_id': gameId, + if (rowid != null) 'rowid': rowid, + }); + } + + StatisticGameTableCompanion copyWith({ + Value? statisticId, + Value? gameId, + Value? rowid, + }) { + return StatisticGameTableCompanion( + statisticId: statisticId ?? this.statisticId, + gameId: gameId ?? this.gameId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (statisticId.present) { + map['statistic_id'] = Variable(statisticId.value); + } + if (gameId.present) { + map['game_id'] = Variable(gameId.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StatisticGameTableCompanion(') + ..write('statisticId: $statisticId, ') + ..write('gameId: $gameId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class $StatisticGroupTableTable extends StatisticGroupTable + with TableInfo<$StatisticGroupTableTable, StatisticGroupTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $StatisticGroupTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _statisticIdMeta = const VerificationMeta( + 'statisticId', + ); + @override + late final GeneratedColumn statisticId = GeneratedColumn( + 'statistic_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES statistic_table (id) ON DELETE CASCADE', + ), + ); + static const VerificationMeta _groupIdMeta = const VerificationMeta( + 'groupId', + ); + @override + late final GeneratedColumn groupId = GeneratedColumn( + 'group_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES group_table (id) ON DELETE CASCADE', + ), + ); + @override + List get $columns => [statisticId, groupId]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'statistic_group_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('statistic_id')) { + context.handle( + _statisticIdMeta, + statisticId.isAcceptableOrUnknown( + data['statistic_id']!, + _statisticIdMeta, + ), + ); + } else if (isInserting) { + context.missing(_statisticIdMeta); + } + if (data.containsKey('group_id')) { + context.handle( + _groupIdMeta, + groupId.isAcceptableOrUnknown(data['group_id']!, _groupIdMeta), + ); + } else if (isInserting) { + context.missing(_groupIdMeta); + } + return context; + } + + @override + Set get $primaryKey => {statisticId, groupId}; + @override + StatisticGroupTableData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StatisticGroupTableData( + statisticId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}statistic_id'], + )!, + groupId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}group_id'], + )!, + ); + } + + @override + $StatisticGroupTableTable createAlias(String alias) { + return $StatisticGroupTableTable(attachedDatabase, alias); + } +} + +class StatisticGroupTableData extends DataClass + implements Insertable { + final String statisticId; + final String groupId; + const StatisticGroupTableData({ + required this.statisticId, + required this.groupId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['statistic_id'] = Variable(statisticId); + map['group_id'] = Variable(groupId); + return map; + } + + StatisticGroupTableCompanion toCompanion(bool nullToAbsent) { + return StatisticGroupTableCompanion( + statisticId: Value(statisticId), + groupId: Value(groupId), + ); + } + + factory StatisticGroupTableData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StatisticGroupTableData( + statisticId: serializer.fromJson(json['statisticId']), + groupId: serializer.fromJson(json['groupId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'statisticId': serializer.toJson(statisticId), + 'groupId': serializer.toJson(groupId), + }; + } + + StatisticGroupTableData copyWith({String? statisticId, String? groupId}) => + StatisticGroupTableData( + statisticId: statisticId ?? this.statisticId, + groupId: groupId ?? this.groupId, + ); + StatisticGroupTableData copyWithCompanion(StatisticGroupTableCompanion data) { + return StatisticGroupTableData( + statisticId: data.statisticId.present + ? data.statisticId.value + : this.statisticId, + groupId: data.groupId.present ? data.groupId.value : this.groupId, + ); + } + + @override + String toString() { + return (StringBuffer('StatisticGroupTableData(') + ..write('statisticId: $statisticId, ') + ..write('groupId: $groupId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(statisticId, groupId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StatisticGroupTableData && + other.statisticId == this.statisticId && + other.groupId == this.groupId); +} + +class StatisticGroupTableCompanion + extends UpdateCompanion { + final Value statisticId; + final Value groupId; + final Value rowid; + const StatisticGroupTableCompanion({ + this.statisticId = const Value.absent(), + this.groupId = const Value.absent(), + this.rowid = const Value.absent(), + }); + StatisticGroupTableCompanion.insert({ + required String statisticId, + required String groupId, + this.rowid = const Value.absent(), + }) : statisticId = Value(statisticId), + groupId = Value(groupId); + static Insertable custom({ + Expression? statisticId, + Expression? groupId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (statisticId != null) 'statistic_id': statisticId, + if (groupId != null) 'group_id': groupId, + if (rowid != null) 'rowid': rowid, + }); + } + + StatisticGroupTableCompanion copyWith({ + Value? statisticId, + Value? groupId, + Value? rowid, + }) { + return StatisticGroupTableCompanion( + statisticId: statisticId ?? this.statisticId, + groupId: groupId ?? this.groupId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (statisticId.present) { + map['statistic_id'] = Variable(statisticId.value); + } + if (groupId.present) { + map['group_id'] = Variable(groupId.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StatisticGroupTableCompanion(') + ..write('statisticId: $statisticId, ') + ..write('groupId: $groupId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + abstract class _$AppDatabase extends GeneratedDatabase { _$AppDatabase(QueryExecutor e) : super(e); $AppDatabaseManager get managers => $AppDatabaseManager(this); @@ -2749,6 +3714,13 @@ abstract class _$AppDatabase extends GeneratedDatabase { late final $ScoreEntryTableTable scoreEntryTable = $ScoreEntryTableTable( this, ); + late final $StatisticTableTable statisticTable = $StatisticTableTable(this); + late final $StatisticScopeTableTable statisticScopeTable = + $StatisticScopeTableTable(this); + late final $StatisticGameTableTable statisticGameTable = + $StatisticGameTableTable(this); + late final $StatisticGroupTableTable statisticGroupTable = + $StatisticGroupTableTable(this); late final PlayerDao playerDao = PlayerDao(this as AppDatabase); late final GroupDao groupDao = GroupDao(this as AppDatabase); late final MatchDao matchDao = MatchDao(this as AppDatabase); @@ -2761,6 +3733,16 @@ abstract class _$AppDatabase extends GeneratedDatabase { late final GameDao gameDao = GameDao(this as AppDatabase); late final ScoreEntryDao scoreEntryDao = ScoreEntryDao(this as AppDatabase); late final TeamDao teamDao = TeamDao(this as AppDatabase); + late final StatisticDao statisticDao = StatisticDao(this as AppDatabase); + late final StatisticScopeDao statisticScopeDao = StatisticScopeDao( + this as AppDatabase, + ); + late final StatisticGameDao statisticGameDao = StatisticGameDao( + this as AppDatabase, + ); + late final StatisticGroupDao statisticGroupDao = StatisticGroupDao( + this as AppDatabase, + ); @override Iterable> get allTables => allSchemaEntities.whereType>(); @@ -2774,6 +3756,10 @@ abstract class _$AppDatabase extends GeneratedDatabase { teamTable, playerMatchTable, scoreEntryTable, + statisticTable, + statisticScopeTable, + statisticGameTable, + statisticGroupTable, ]; @override StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ @@ -2840,6 +3826,41 @@ abstract class _$AppDatabase extends GeneratedDatabase { ), result: [TableUpdate('score_entry_table', kind: UpdateKind.delete)], ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'statistic_table', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('statistic_scope_table', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'statistic_table', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('statistic_game_table', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'game_table', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('statistic_game_table', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'statistic_table', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('statistic_group_table', kind: UpdateKind.delete)], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'group_table', + limitUpdateKind: UpdateKind.delete, + ), + result: [TableUpdate('statistic_group_table', kind: UpdateKind.delete)], + ), ]); } @@ -3419,6 +4440,33 @@ final class $$GroupTableTableReferences manager.$state.copyWith(prefetchedData: cache), ); } + + static MultiTypedResultKey< + $StatisticGroupTableTable, + List + > + _statisticGroupTableRefsTable(_$AppDatabase db) => + MultiTypedResultKey.fromTable( + db.statisticGroupTable, + aliasName: $_aliasNameGenerator( + db.groupTable.id, + db.statisticGroupTable.groupId, + ), + ); + + $$StatisticGroupTableTableProcessedTableManager get statisticGroupTableRefs { + final manager = $$StatisticGroupTableTableTableManager( + $_db, + $_db.statisticGroupTable, + ).filter((f) => f.groupId.id.sqlEquals($_itemColumn('id')!)); + + final cache = $_typedResult.readTableOrNull( + _statisticGroupTableRefsTable($_db), + ); + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: cache), + ); + } } class $$GroupTableTableFilterComposer @@ -3499,6 +4547,31 @@ class $$GroupTableTableFilterComposer ); return f(composer); } + + Expression statisticGroupTableRefs( + Expression Function($$StatisticGroupTableTableFilterComposer f) f, + ) { + final $$StatisticGroupTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGroupTable, + getReferencedColumn: (t) => t.groupId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGroupTableTableFilterComposer( + $db: $db, + $table: $db.statisticGroupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } } class $$GroupTableTableOrderingComposer @@ -3603,6 +4676,32 @@ class $$GroupTableTableAnnotationComposer ); return f(composer); } + + Expression statisticGroupTableRefs( + Expression Function($$StatisticGroupTableTableAnnotationComposer a) f, + ) { + final $$StatisticGroupTableTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGroupTable, + getReferencedColumn: (t) => t.groupId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGroupTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticGroupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } } class $$GroupTableTableTableManager @@ -3621,6 +4720,7 @@ class $$GroupTableTableTableManager PrefetchHooks Function({ bool matchTableRefs, bool playerGroupTableRefs, + bool statisticGroupTableRefs, }) > { $$GroupTableTableTableManager(_$AppDatabase db, $GroupTableTable table) @@ -3671,12 +4771,17 @@ class $$GroupTableTableTableManager ) .toList(), prefetchHooksCallback: - ({matchTableRefs = false, playerGroupTableRefs = false}) { + ({ + matchTableRefs = false, + playerGroupTableRefs = false, + statisticGroupTableRefs = false, + }) { return PrefetchHooks( db: db, explicitlyWatchedTables: [ if (matchTableRefs) db.matchTable, if (playerGroupTableRefs) db.playerGroupTable, + if (statisticGroupTableRefs) db.statisticGroupTable, ], addJoins: null, getPrefetchedDataCallback: (items) async { @@ -3723,6 +4828,27 @@ class $$GroupTableTableTableManager ), typedResults: items, ), + if (statisticGroupTableRefs) + await $_getPrefetchedData< + GroupTableData, + $GroupTableTable, + StatisticGroupTableData + >( + currentTable: table, + referencedTable: $$GroupTableTableReferences + ._statisticGroupTableRefsTable(db), + managerFromTypedResult: (p0) => + $$GroupTableTableReferences( + db, + table, + p0, + ).statisticGroupTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.groupId == item.id, + ), + typedResults: items, + ), ]; }, ); @@ -3743,7 +4869,11 @@ typedef $$GroupTableTableProcessedTableManager = $$GroupTableTableUpdateCompanionBuilder, (GroupTableData, $$GroupTableTableReferences), GroupTableData, - PrefetchHooks Function({bool matchTableRefs, bool playerGroupTableRefs}) + PrefetchHooks Function({ + bool matchTableRefs, + bool playerGroupTableRefs, + bool statisticGroupTableRefs, + }) >; typedef $$GameTableTableCreateCompanionBuilder = GameTableCompanion Function({ @@ -3789,6 +4919,33 @@ final class $$GameTableTableReferences manager.$state.copyWith(prefetchedData: cache), ); } + + static MultiTypedResultKey< + $StatisticGameTableTable, + List + > + _statisticGameTableRefsTable(_$AppDatabase db) => + MultiTypedResultKey.fromTable( + db.statisticGameTable, + aliasName: $_aliasNameGenerator( + db.gameTable.id, + db.statisticGameTable.gameId, + ), + ); + + $$StatisticGameTableTableProcessedTableManager get statisticGameTableRefs { + final manager = $$StatisticGameTableTableTableManager( + $_db, + $_db.statisticGameTable, + ).filter((f) => f.gameId.id.sqlEquals($_itemColumn('id')!)); + + final cache = $_typedResult.readTableOrNull( + _statisticGameTableRefsTable($_db), + ); + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: cache), + ); + } } class $$GameTableTableFilterComposer @@ -3859,6 +5016,31 @@ class $$GameTableTableFilterComposer ); return f(composer); } + + Expression statisticGameTableRefs( + Expression Function($$StatisticGameTableTableFilterComposer f) f, + ) { + final $$StatisticGameTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGameTable, + getReferencedColumn: (t) => t.gameId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGameTableTableFilterComposer( + $db: $db, + $table: $db.statisticGameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } } class $$GameTableTableOrderingComposer @@ -3962,6 +5144,32 @@ class $$GameTableTableAnnotationComposer ); return f(composer); } + + Expression statisticGameTableRefs( + Expression Function($$StatisticGameTableTableAnnotationComposer a) f, + ) { + final $$StatisticGameTableTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGameTable, + getReferencedColumn: (t) => t.gameId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGameTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticGameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } } class $$GameTableTableTableManager @@ -3977,7 +5185,10 @@ class $$GameTableTableTableManager $$GameTableTableUpdateCompanionBuilder, (GameTableData, $$GameTableTableReferences), GameTableData, - PrefetchHooks Function({bool matchTableRefs}) + PrefetchHooks Function({ + bool matchTableRefs, + bool statisticGameTableRefs, + }) > { $$GameTableTableTableManager(_$AppDatabase db, $GameTableTable table) : super( @@ -4038,36 +5249,63 @@ class $$GameTableTableTableManager ), ) .toList(), - prefetchHooksCallback: ({matchTableRefs = false}) { - return PrefetchHooks( - db: db, - explicitlyWatchedTables: [if (matchTableRefs) db.matchTable], - addJoins: null, - getPrefetchedDataCallback: (items) async { - return [ - if (matchTableRefs) - await $_getPrefetchedData< - GameTableData, - $GameTableTable, - MatchTableData - >( - currentTable: table, - referencedTable: $$GameTableTableReferences - ._matchTableRefsTable(db), - managerFromTypedResult: (p0) => - $$GameTableTableReferences( - db, - table, - p0, - ).matchTableRefs, - referencedItemsForCurrentItem: (item, referencedItems) => - referencedItems.where((e) => e.gameId == item.id), - typedResults: items, - ), - ]; + prefetchHooksCallback: + ({matchTableRefs = false, statisticGameTableRefs = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [ + if (matchTableRefs) db.matchTable, + if (statisticGameTableRefs) db.statisticGameTable, + ], + addJoins: null, + getPrefetchedDataCallback: (items) async { + return [ + if (matchTableRefs) + await $_getPrefetchedData< + GameTableData, + $GameTableTable, + MatchTableData + >( + currentTable: table, + referencedTable: $$GameTableTableReferences + ._matchTableRefsTable(db), + managerFromTypedResult: (p0) => + $$GameTableTableReferences( + db, + table, + p0, + ).matchTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.gameId == item.id, + ), + typedResults: items, + ), + if (statisticGameTableRefs) + await $_getPrefetchedData< + GameTableData, + $GameTableTable, + StatisticGameTableData + >( + currentTable: table, + referencedTable: $$GameTableTableReferences + ._statisticGameTableRefsTable(db), + managerFromTypedResult: (p0) => + $$GameTableTableReferences( + db, + table, + p0, + ).statisticGameTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.gameId == item.id, + ), + typedResults: items, + ), + ]; + }, + ); }, - ); - }, ), ); } @@ -4084,7 +5322,7 @@ typedef $$GameTableTableProcessedTableManager = $$GameTableTableUpdateCompanionBuilder, (GameTableData, $$GameTableTableReferences), GameTableData, - PrefetchHooks Function({bool matchTableRefs}) + PrefetchHooks Function({bool matchTableRefs, bool statisticGameTableRefs}) >; typedef $$MatchTableTableCreateCompanionBuilder = MatchTableCompanion Function({ @@ -6273,6 +7511,1536 @@ typedef $$ScoreEntryTableTableProcessedTableManager = ScoreEntryTableData, PrefetchHooks Function({bool playerId, bool matchId}) >; +typedef $$StatisticTableTableCreateCompanionBuilder = + StatisticTableCompanion Function({ + required String id, + required String type, + Value timeframe, + Value rowid, + }); +typedef $$StatisticTableTableUpdateCompanionBuilder = + StatisticTableCompanion Function({ + Value id, + Value type, + Value timeframe, + Value rowid, + }); + +final class $$StatisticTableTableReferences + extends + BaseReferences< + _$AppDatabase, + $StatisticTableTable, + StatisticTableData + > { + $$StatisticTableTableReferences( + super.$_db, + super.$_table, + super.$_typedResult, + ); + + static MultiTypedResultKey< + $StatisticScopeTableTable, + List + > + _statisticScopeTableRefsTable(_$AppDatabase db) => + MultiTypedResultKey.fromTable( + db.statisticScopeTable, + aliasName: $_aliasNameGenerator( + db.statisticTable.id, + db.statisticScopeTable.statisticId, + ), + ); + + $$StatisticScopeTableTableProcessedTableManager get statisticScopeTableRefs { + final manager = $$StatisticScopeTableTableTableManager( + $_db, + $_db.statisticScopeTable, + ).filter((f) => f.statisticId.id.sqlEquals($_itemColumn('id')!)); + + final cache = $_typedResult.readTableOrNull( + _statisticScopeTableRefsTable($_db), + ); + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: cache), + ); + } + + static MultiTypedResultKey< + $StatisticGameTableTable, + List + > + _statisticGameTableRefsTable(_$AppDatabase db) => + MultiTypedResultKey.fromTable( + db.statisticGameTable, + aliasName: $_aliasNameGenerator( + db.statisticTable.id, + db.statisticGameTable.statisticId, + ), + ); + + $$StatisticGameTableTableProcessedTableManager get statisticGameTableRefs { + final manager = $$StatisticGameTableTableTableManager( + $_db, + $_db.statisticGameTable, + ).filter((f) => f.statisticId.id.sqlEquals($_itemColumn('id')!)); + + final cache = $_typedResult.readTableOrNull( + _statisticGameTableRefsTable($_db), + ); + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: cache), + ); + } + + static MultiTypedResultKey< + $StatisticGroupTableTable, + List + > + _statisticGroupTableRefsTable(_$AppDatabase db) => + MultiTypedResultKey.fromTable( + db.statisticGroupTable, + aliasName: $_aliasNameGenerator( + db.statisticTable.id, + db.statisticGroupTable.statisticId, + ), + ); + + $$StatisticGroupTableTableProcessedTableManager get statisticGroupTableRefs { + final manager = $$StatisticGroupTableTableTableManager( + $_db, + $_db.statisticGroupTable, + ).filter((f) => f.statisticId.id.sqlEquals($_itemColumn('id')!)); + + final cache = $_typedResult.readTableOrNull( + _statisticGroupTableRefsTable($_db), + ); + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: cache), + ); + } +} + +class $$StatisticTableTableFilterComposer + extends Composer<_$AppDatabase, $StatisticTableTable> { + $$StatisticTableTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get type => $composableBuilder( + column: $table.type, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get timeframe => $composableBuilder( + column: $table.timeframe, + builder: (column) => ColumnFilters(column), + ); + + Expression statisticScopeTableRefs( + Expression Function($$StatisticScopeTableTableFilterComposer f) f, + ) { + final $$StatisticScopeTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticScopeTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticScopeTableTableFilterComposer( + $db: $db, + $table: $db.statisticScopeTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } + + Expression statisticGameTableRefs( + Expression Function($$StatisticGameTableTableFilterComposer f) f, + ) { + final $$StatisticGameTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGameTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGameTableTableFilterComposer( + $db: $db, + $table: $db.statisticGameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } + + Expression statisticGroupTableRefs( + Expression Function($$StatisticGroupTableTableFilterComposer f) f, + ) { + final $$StatisticGroupTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGroupTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGroupTableTableFilterComposer( + $db: $db, + $table: $db.statisticGroupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } +} + +class $$StatisticTableTableOrderingComposer + extends Composer<_$AppDatabase, $StatisticTableTable> { + $$StatisticTableTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get type => $composableBuilder( + column: $table.type, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get timeframe => $composableBuilder( + column: $table.timeframe, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$StatisticTableTableAnnotationComposer + extends Composer<_$AppDatabase, $StatisticTableTable> { + $$StatisticTableTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumn get type => + $composableBuilder(column: $table.type, builder: (column) => column); + + GeneratedColumn get timeframe => + $composableBuilder(column: $table.timeframe, builder: (column) => column); + + Expression statisticScopeTableRefs( + Expression Function($$StatisticScopeTableTableAnnotationComposer a) f, + ) { + final $$StatisticScopeTableTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticScopeTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticScopeTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticScopeTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } + + Expression statisticGameTableRefs( + Expression Function($$StatisticGameTableTableAnnotationComposer a) f, + ) { + final $$StatisticGameTableTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGameTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGameTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticGameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } + + Expression statisticGroupTableRefs( + Expression Function($$StatisticGroupTableTableAnnotationComposer a) f, + ) { + final $$StatisticGroupTableTableAnnotationComposer composer = + $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $db.statisticGroupTable, + getReferencedColumn: (t) => t.statisticId, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticGroupTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticGroupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return f(composer); + } +} + +class $$StatisticTableTableTableManager + extends + RootTableManager< + _$AppDatabase, + $StatisticTableTable, + StatisticTableData, + $$StatisticTableTableFilterComposer, + $$StatisticTableTableOrderingComposer, + $$StatisticTableTableAnnotationComposer, + $$StatisticTableTableCreateCompanionBuilder, + $$StatisticTableTableUpdateCompanionBuilder, + (StatisticTableData, $$StatisticTableTableReferences), + StatisticTableData, + PrefetchHooks Function({ + bool statisticScopeTableRefs, + bool statisticGameTableRefs, + bool statisticGroupTableRefs, + }) + > { + $$StatisticTableTableTableManager( + _$AppDatabase db, + $StatisticTableTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$StatisticTableTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$StatisticTableTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$StatisticTableTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value type = const Value.absent(), + Value timeframe = const Value.absent(), + Value rowid = const Value.absent(), + }) => StatisticTableCompanion( + id: id, + type: type, + timeframe: timeframe, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String id, + required String type, + Value timeframe = const Value.absent(), + Value rowid = const Value.absent(), + }) => StatisticTableCompanion.insert( + id: id, + type: type, + timeframe: timeframe, + rowid: rowid, + ), + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$StatisticTableTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: + ({ + statisticScopeTableRefs = false, + statisticGameTableRefs = false, + statisticGroupTableRefs = false, + }) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [ + if (statisticScopeTableRefs) db.statisticScopeTable, + if (statisticGameTableRefs) db.statisticGameTable, + if (statisticGroupTableRefs) db.statisticGroupTable, + ], + addJoins: null, + getPrefetchedDataCallback: (items) async { + return [ + if (statisticScopeTableRefs) + await $_getPrefetchedData< + StatisticTableData, + $StatisticTableTable, + StatisticScopeTableData + >( + currentTable: table, + referencedTable: $$StatisticTableTableReferences + ._statisticScopeTableRefsTable(db), + managerFromTypedResult: (p0) => + $$StatisticTableTableReferences( + db, + table, + p0, + ).statisticScopeTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.statisticId == item.id, + ), + typedResults: items, + ), + if (statisticGameTableRefs) + await $_getPrefetchedData< + StatisticTableData, + $StatisticTableTable, + StatisticGameTableData + >( + currentTable: table, + referencedTable: $$StatisticTableTableReferences + ._statisticGameTableRefsTable(db), + managerFromTypedResult: (p0) => + $$StatisticTableTableReferences( + db, + table, + p0, + ).statisticGameTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.statisticId == item.id, + ), + typedResults: items, + ), + if (statisticGroupTableRefs) + await $_getPrefetchedData< + StatisticTableData, + $StatisticTableTable, + StatisticGroupTableData + >( + currentTable: table, + referencedTable: $$StatisticTableTableReferences + ._statisticGroupTableRefsTable(db), + managerFromTypedResult: (p0) => + $$StatisticTableTableReferences( + db, + table, + p0, + ).statisticGroupTableRefs, + referencedItemsForCurrentItem: + (item, referencedItems) => referencedItems.where( + (e) => e.statisticId == item.id, + ), + typedResults: items, + ), + ]; + }, + ); + }, + ), + ); +} + +typedef $$StatisticTableTableProcessedTableManager = + ProcessedTableManager< + _$AppDatabase, + $StatisticTableTable, + StatisticTableData, + $$StatisticTableTableFilterComposer, + $$StatisticTableTableOrderingComposer, + $$StatisticTableTableAnnotationComposer, + $$StatisticTableTableCreateCompanionBuilder, + $$StatisticTableTableUpdateCompanionBuilder, + (StatisticTableData, $$StatisticTableTableReferences), + StatisticTableData, + PrefetchHooks Function({ + bool statisticScopeTableRefs, + bool statisticGameTableRefs, + bool statisticGroupTableRefs, + }) + >; +typedef $$StatisticScopeTableTableCreateCompanionBuilder = + StatisticScopeTableCompanion Function({ + required String statisticId, + required String scope, + Value rowid, + }); +typedef $$StatisticScopeTableTableUpdateCompanionBuilder = + StatisticScopeTableCompanion Function({ + Value statisticId, + Value scope, + Value rowid, + }); + +final class $$StatisticScopeTableTableReferences + extends + BaseReferences< + _$AppDatabase, + $StatisticScopeTableTable, + StatisticScopeTableData + > { + $$StatisticScopeTableTableReferences( + super.$_db, + super.$_table, + super.$_typedResult, + ); + + static $StatisticTableTable _statisticIdTable(_$AppDatabase db) => + db.statisticTable.createAlias( + $_aliasNameGenerator( + db.statisticScopeTable.statisticId, + db.statisticTable.id, + ), + ); + + $$StatisticTableTableProcessedTableManager get statisticId { + final $_column = $_itemColumn('statistic_id')!; + + final manager = $$StatisticTableTableTableManager( + $_db, + $_db.statisticTable, + ).filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_statisticIdTable($_db)); + if (item == null) return manager; + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item]), + ); + } +} + +class $$StatisticScopeTableTableFilterComposer + extends Composer<_$AppDatabase, $StatisticScopeTableTable> { + $$StatisticScopeTableTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get scope => $composableBuilder( + column: $table.scope, + builder: (column) => ColumnFilters(column), + ); + + $$StatisticTableTableFilterComposer get statisticId { + final $$StatisticTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableFilterComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticScopeTableTableOrderingComposer + extends Composer<_$AppDatabase, $StatisticScopeTableTable> { + $$StatisticScopeTableTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get scope => $composableBuilder( + column: $table.scope, + builder: (column) => ColumnOrderings(column), + ); + + $$StatisticTableTableOrderingComposer get statisticId { + final $$StatisticTableTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableOrderingComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticScopeTableTableAnnotationComposer + extends Composer<_$AppDatabase, $StatisticScopeTableTable> { + $$StatisticScopeTableTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get scope => + $composableBuilder(column: $table.scope, builder: (column) => column); + + $$StatisticTableTableAnnotationComposer get statisticId { + final $$StatisticTableTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticScopeTableTableTableManager + extends + RootTableManager< + _$AppDatabase, + $StatisticScopeTableTable, + StatisticScopeTableData, + $$StatisticScopeTableTableFilterComposer, + $$StatisticScopeTableTableOrderingComposer, + $$StatisticScopeTableTableAnnotationComposer, + $$StatisticScopeTableTableCreateCompanionBuilder, + $$StatisticScopeTableTableUpdateCompanionBuilder, + (StatisticScopeTableData, $$StatisticScopeTableTableReferences), + StatisticScopeTableData, + PrefetchHooks Function({bool statisticId}) + > { + $$StatisticScopeTableTableTableManager( + _$AppDatabase db, + $StatisticScopeTableTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$StatisticScopeTableTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$StatisticScopeTableTableOrderingComposer( + $db: db, + $table: table, + ), + createComputedFieldComposer: () => + $$StatisticScopeTableTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value statisticId = const Value.absent(), + Value scope = const Value.absent(), + Value rowid = const Value.absent(), + }) => StatisticScopeTableCompanion( + statisticId: statisticId, + scope: scope, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String statisticId, + required String scope, + Value rowid = const Value.absent(), + }) => StatisticScopeTableCompanion.insert( + statisticId: statisticId, + scope: scope, + rowid: rowid, + ), + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$StatisticScopeTableTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: ({statisticId = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [], + addJoins: + < + T extends TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic + > + >(state) { + if (statisticId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.statisticId, + referencedTable: + $$StatisticScopeTableTableReferences + ._statisticIdTable(db), + referencedColumn: + $$StatisticScopeTableTableReferences + ._statisticIdTable(db) + .id, + ) + as T; + } + + return state; + }, + getPrefetchedDataCallback: (items) async { + return []; + }, + ); + }, + ), + ); +} + +typedef $$StatisticScopeTableTableProcessedTableManager = + ProcessedTableManager< + _$AppDatabase, + $StatisticScopeTableTable, + StatisticScopeTableData, + $$StatisticScopeTableTableFilterComposer, + $$StatisticScopeTableTableOrderingComposer, + $$StatisticScopeTableTableAnnotationComposer, + $$StatisticScopeTableTableCreateCompanionBuilder, + $$StatisticScopeTableTableUpdateCompanionBuilder, + (StatisticScopeTableData, $$StatisticScopeTableTableReferences), + StatisticScopeTableData, + PrefetchHooks Function({bool statisticId}) + >; +typedef $$StatisticGameTableTableCreateCompanionBuilder = + StatisticGameTableCompanion Function({ + required String statisticId, + required String gameId, + Value rowid, + }); +typedef $$StatisticGameTableTableUpdateCompanionBuilder = + StatisticGameTableCompanion Function({ + Value statisticId, + Value gameId, + Value rowid, + }); + +final class $$StatisticGameTableTableReferences + extends + BaseReferences< + _$AppDatabase, + $StatisticGameTableTable, + StatisticGameTableData + > { + $$StatisticGameTableTableReferences( + super.$_db, + super.$_table, + super.$_typedResult, + ); + + static $StatisticTableTable _statisticIdTable(_$AppDatabase db) => + db.statisticTable.createAlias( + $_aliasNameGenerator( + db.statisticGameTable.statisticId, + db.statisticTable.id, + ), + ); + + $$StatisticTableTableProcessedTableManager get statisticId { + final $_column = $_itemColumn('statistic_id')!; + + final manager = $$StatisticTableTableTableManager( + $_db, + $_db.statisticTable, + ).filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_statisticIdTable($_db)); + if (item == null) return manager; + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item]), + ); + } + + static $GameTableTable _gameIdTable(_$AppDatabase db) => + db.gameTable.createAlias( + $_aliasNameGenerator(db.statisticGameTable.gameId, db.gameTable.id), + ); + + $$GameTableTableProcessedTableManager get gameId { + final $_column = $_itemColumn('game_id')!; + + final manager = $$GameTableTableTableManager( + $_db, + $_db.gameTable, + ).filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_gameIdTable($_db)); + if (item == null) return manager; + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item]), + ); + } +} + +class $$StatisticGameTableTableFilterComposer + extends Composer<_$AppDatabase, $StatisticGameTableTable> { + $$StatisticGameTableTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableFilterComposer get statisticId { + final $$StatisticTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableFilterComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GameTableTableFilterComposer get gameId { + final $$GameTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.gameId, + referencedTable: $db.gameTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GameTableTableFilterComposer( + $db: $db, + $table: $db.gameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGameTableTableOrderingComposer + extends Composer<_$AppDatabase, $StatisticGameTableTable> { + $$StatisticGameTableTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableOrderingComposer get statisticId { + final $$StatisticTableTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableOrderingComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GameTableTableOrderingComposer get gameId { + final $$GameTableTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.gameId, + referencedTable: $db.gameTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GameTableTableOrderingComposer( + $db: $db, + $table: $db.gameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGameTableTableAnnotationComposer + extends Composer<_$AppDatabase, $StatisticGameTableTable> { + $$StatisticGameTableTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableAnnotationComposer get statisticId { + final $$StatisticTableTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GameTableTableAnnotationComposer get gameId { + final $$GameTableTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.gameId, + referencedTable: $db.gameTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GameTableTableAnnotationComposer( + $db: $db, + $table: $db.gameTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGameTableTableTableManager + extends + RootTableManager< + _$AppDatabase, + $StatisticGameTableTable, + StatisticGameTableData, + $$StatisticGameTableTableFilterComposer, + $$StatisticGameTableTableOrderingComposer, + $$StatisticGameTableTableAnnotationComposer, + $$StatisticGameTableTableCreateCompanionBuilder, + $$StatisticGameTableTableUpdateCompanionBuilder, + (StatisticGameTableData, $$StatisticGameTableTableReferences), + StatisticGameTableData, + PrefetchHooks Function({bool statisticId, bool gameId}) + > { + $$StatisticGameTableTableTableManager( + _$AppDatabase db, + $StatisticGameTableTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$StatisticGameTableTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$StatisticGameTableTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$StatisticGameTableTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value statisticId = const Value.absent(), + Value gameId = const Value.absent(), + Value rowid = const Value.absent(), + }) => StatisticGameTableCompanion( + statisticId: statisticId, + gameId: gameId, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String statisticId, + required String gameId, + Value rowid = const Value.absent(), + }) => StatisticGameTableCompanion.insert( + statisticId: statisticId, + gameId: gameId, + rowid: rowid, + ), + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$StatisticGameTableTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: ({statisticId = false, gameId = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [], + addJoins: + < + T extends TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic + > + >(state) { + if (statisticId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.statisticId, + referencedTable: + $$StatisticGameTableTableReferences + ._statisticIdTable(db), + referencedColumn: + $$StatisticGameTableTableReferences + ._statisticIdTable(db) + .id, + ) + as T; + } + if (gameId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.gameId, + referencedTable: + $$StatisticGameTableTableReferences + ._gameIdTable(db), + referencedColumn: + $$StatisticGameTableTableReferences + ._gameIdTable(db) + .id, + ) + as T; + } + + return state; + }, + getPrefetchedDataCallback: (items) async { + return []; + }, + ); + }, + ), + ); +} + +typedef $$StatisticGameTableTableProcessedTableManager = + ProcessedTableManager< + _$AppDatabase, + $StatisticGameTableTable, + StatisticGameTableData, + $$StatisticGameTableTableFilterComposer, + $$StatisticGameTableTableOrderingComposer, + $$StatisticGameTableTableAnnotationComposer, + $$StatisticGameTableTableCreateCompanionBuilder, + $$StatisticGameTableTableUpdateCompanionBuilder, + (StatisticGameTableData, $$StatisticGameTableTableReferences), + StatisticGameTableData, + PrefetchHooks Function({bool statisticId, bool gameId}) + >; +typedef $$StatisticGroupTableTableCreateCompanionBuilder = + StatisticGroupTableCompanion Function({ + required String statisticId, + required String groupId, + Value rowid, + }); +typedef $$StatisticGroupTableTableUpdateCompanionBuilder = + StatisticGroupTableCompanion Function({ + Value statisticId, + Value groupId, + Value rowid, + }); + +final class $$StatisticGroupTableTableReferences + extends + BaseReferences< + _$AppDatabase, + $StatisticGroupTableTable, + StatisticGroupTableData + > { + $$StatisticGroupTableTableReferences( + super.$_db, + super.$_table, + super.$_typedResult, + ); + + static $StatisticTableTable _statisticIdTable(_$AppDatabase db) => + db.statisticTable.createAlias( + $_aliasNameGenerator( + db.statisticGroupTable.statisticId, + db.statisticTable.id, + ), + ); + + $$StatisticTableTableProcessedTableManager get statisticId { + final $_column = $_itemColumn('statistic_id')!; + + final manager = $$StatisticTableTableTableManager( + $_db, + $_db.statisticTable, + ).filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_statisticIdTable($_db)); + if (item == null) return manager; + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item]), + ); + } + + static $GroupTableTable _groupIdTable(_$AppDatabase db) => + db.groupTable.createAlias( + $_aliasNameGenerator(db.statisticGroupTable.groupId, db.groupTable.id), + ); + + $$GroupTableTableProcessedTableManager get groupId { + final $_column = $_itemColumn('group_id')!; + + final manager = $$GroupTableTableTableManager( + $_db, + $_db.groupTable, + ).filter((f) => f.id.sqlEquals($_column)); + final item = $_typedResult.readTableOrNull(_groupIdTable($_db)); + if (item == null) return manager; + return ProcessedTableManager( + manager.$state.copyWith(prefetchedData: [item]), + ); + } +} + +class $$StatisticGroupTableTableFilterComposer + extends Composer<_$AppDatabase, $StatisticGroupTableTable> { + $$StatisticGroupTableTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableFilterComposer get statisticId { + final $$StatisticTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableFilterComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GroupTableTableFilterComposer get groupId { + final $$GroupTableTableFilterComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.groupId, + referencedTable: $db.groupTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GroupTableTableFilterComposer( + $db: $db, + $table: $db.groupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGroupTableTableOrderingComposer + extends Composer<_$AppDatabase, $StatisticGroupTableTable> { + $$StatisticGroupTableTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableOrderingComposer get statisticId { + final $$StatisticTableTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableOrderingComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GroupTableTableOrderingComposer get groupId { + final $$GroupTableTableOrderingComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.groupId, + referencedTable: $db.groupTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GroupTableTableOrderingComposer( + $db: $db, + $table: $db.groupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGroupTableTableAnnotationComposer + extends Composer<_$AppDatabase, $StatisticGroupTableTable> { + $$StatisticGroupTableTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + $$StatisticTableTableAnnotationComposer get statisticId { + final $$StatisticTableTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.statisticId, + referencedTable: $db.statisticTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$StatisticTableTableAnnotationComposer( + $db: $db, + $table: $db.statisticTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } + + $$GroupTableTableAnnotationComposer get groupId { + final $$GroupTableTableAnnotationComposer composer = $composerBuilder( + composer: this, + getCurrentColumn: (t) => t.groupId, + referencedTable: $db.groupTable, + getReferencedColumn: (t) => t.id, + builder: + ( + joinBuilder, { + $addJoinBuilderToRootComposer, + $removeJoinBuilderFromRootComposer, + }) => $$GroupTableTableAnnotationComposer( + $db: $db, + $table: $db.groupTable, + $addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer, + joinBuilder: joinBuilder, + $removeJoinBuilderFromRootComposer: + $removeJoinBuilderFromRootComposer, + ), + ); + return composer; + } +} + +class $$StatisticGroupTableTableTableManager + extends + RootTableManager< + _$AppDatabase, + $StatisticGroupTableTable, + StatisticGroupTableData, + $$StatisticGroupTableTableFilterComposer, + $$StatisticGroupTableTableOrderingComposer, + $$StatisticGroupTableTableAnnotationComposer, + $$StatisticGroupTableTableCreateCompanionBuilder, + $$StatisticGroupTableTableUpdateCompanionBuilder, + (StatisticGroupTableData, $$StatisticGroupTableTableReferences), + StatisticGroupTableData, + PrefetchHooks Function({bool statisticId, bool groupId}) + > { + $$StatisticGroupTableTableTableManager( + _$AppDatabase db, + $StatisticGroupTableTable table, + ) : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$StatisticGroupTableTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$StatisticGroupTableTableOrderingComposer( + $db: db, + $table: table, + ), + createComputedFieldComposer: () => + $$StatisticGroupTableTableAnnotationComposer( + $db: db, + $table: table, + ), + updateCompanionCallback: + ({ + Value statisticId = const Value.absent(), + Value groupId = const Value.absent(), + Value rowid = const Value.absent(), + }) => StatisticGroupTableCompanion( + statisticId: statisticId, + groupId: groupId, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String statisticId, + required String groupId, + Value rowid = const Value.absent(), + }) => StatisticGroupTableCompanion.insert( + statisticId: statisticId, + groupId: groupId, + rowid: rowid, + ), + withReferenceMapper: (p0) => p0 + .map( + (e) => ( + e.readTable(table), + $$StatisticGroupTableTableReferences(db, table, e), + ), + ) + .toList(), + prefetchHooksCallback: ({statisticId = false, groupId = false}) { + return PrefetchHooks( + db: db, + explicitlyWatchedTables: [], + addJoins: + < + T extends TableManagerState< + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic, + dynamic + > + >(state) { + if (statisticId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.statisticId, + referencedTable: + $$StatisticGroupTableTableReferences + ._statisticIdTable(db), + referencedColumn: + $$StatisticGroupTableTableReferences + ._statisticIdTable(db) + .id, + ) + as T; + } + if (groupId) { + state = + state.withJoin( + currentTable: table, + currentColumn: table.groupId, + referencedTable: + $$StatisticGroupTableTableReferences + ._groupIdTable(db), + referencedColumn: + $$StatisticGroupTableTableReferences + ._groupIdTable(db) + .id, + ) + as T; + } + + return state; + }, + getPrefetchedDataCallback: (items) async { + return []; + }, + ); + }, + ), + ); +} + +typedef $$StatisticGroupTableTableProcessedTableManager = + ProcessedTableManager< + _$AppDatabase, + $StatisticGroupTableTable, + StatisticGroupTableData, + $$StatisticGroupTableTableFilterComposer, + $$StatisticGroupTableTableOrderingComposer, + $$StatisticGroupTableTableAnnotationComposer, + $$StatisticGroupTableTableCreateCompanionBuilder, + $$StatisticGroupTableTableUpdateCompanionBuilder, + (StatisticGroupTableData, $$StatisticGroupTableTableReferences), + StatisticGroupTableData, + PrefetchHooks Function({bool statisticId, bool groupId}) + >; class $AppDatabaseManager { final _$AppDatabase _db; @@ -6293,4 +9061,12 @@ class $AppDatabaseManager { $$PlayerMatchTableTableTableManager(_db, _db.playerMatchTable); $$ScoreEntryTableTableTableManager get scoreEntryTable => $$ScoreEntryTableTableTableManager(_db, _db.scoreEntryTable); + $$StatisticTableTableTableManager get statisticTable => + $$StatisticTableTableTableManager(_db, _db.statisticTable); + $$StatisticScopeTableTableTableManager get statisticScopeTable => + $$StatisticScopeTableTableTableManager(_db, _db.statisticScopeTable); + $$StatisticGameTableTableTableManager get statisticGameTable => + $$StatisticGameTableTableTableManager(_db, _db.statisticGameTable); + $$StatisticGroupTableTableTableManager get statisticGroupTable => + $$StatisticGroupTableTableTableManager(_db, _db.statisticGroupTable); } diff --git a/lib/data/db/tables/statistic_game_table.dart b/lib/data/db/tables/statistic_game_table.dart new file mode 100644 index 0000000..e1cc7d4 --- /dev/null +++ b/lib/data/db/tables/statistic_game_table.dart @@ -0,0 +1,13 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/data/db/tables/game_table.dart'; +import 'package:tallee/data/db/tables/statistic_table.dart'; + +class StatisticGameTable extends Table { + TextColumn get statisticId => + text().references(StatisticTable, #id, onDelete: KeyAction.cascade)(); + TextColumn get gameId => + text().references(GameTable, #id, onDelete: KeyAction.cascade)(); + + @override + Set> get primaryKey => {statisticId, gameId}; +} diff --git a/lib/data/db/tables/statistic_group_table.dart b/lib/data/db/tables/statistic_group_table.dart new file mode 100644 index 0000000..cd642ad --- /dev/null +++ b/lib/data/db/tables/statistic_group_table.dart @@ -0,0 +1,13 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/data/db/tables/group_table.dart'; +import 'package:tallee/data/db/tables/statistic_table.dart'; + +class StatisticGroupTable extends Table { + TextColumn get statisticId => + text().references(StatisticTable, #id, onDelete: KeyAction.cascade)(); + TextColumn get groupId => + text().references(GroupTable, #id, onDelete: KeyAction.cascade)(); + + @override + Set> get primaryKey => {statisticId, groupId}; +} diff --git a/lib/data/db/tables/statistic_scope_table.dart b/lib/data/db/tables/statistic_scope_table.dart new file mode 100644 index 0000000..3a9bcdc --- /dev/null +++ b/lib/data/db/tables/statistic_scope_table.dart @@ -0,0 +1,11 @@ +import 'package:drift/drift.dart'; +import 'package:tallee/data/db/tables/statistic_table.dart'; + +class StatisticScopeTable extends Table { + TextColumn get statisticId => + text().references(StatisticTable, #id, onDelete: KeyAction.cascade)(); + TextColumn get scope => text()(); + + @override + Set> get primaryKey => {statisticId, scope}; +} diff --git a/lib/data/db/tables/statistic_table.dart b/lib/data/db/tables/statistic_table.dart new file mode 100644 index 0000000..d627894 --- /dev/null +++ b/lib/data/db/tables/statistic_table.dart @@ -0,0 +1,10 @@ +import 'package:drift/drift.dart'; + +class StatisticTable extends Table { + TextColumn get id => text()(); + TextColumn get type => text()(); + TextColumn get timeframe => text().nullable()(); + + @override + Set> get primaryKey => {id}; +} diff --git a/lib/data/models/statistic.dart b/lib/data/models/statistic.dart index 4b5df07..3d118f7 100644 --- a/lib/data/models/statistic.dart +++ b/lib/data/models/statistic.dart @@ -1,8 +1,10 @@ import 'package:tallee/core/enums.dart'; import 'package:tallee/data/models/game.dart'; import 'package:tallee/data/models/group.dart'; +import 'package:uuid/uuid.dart'; class Statistic { + final String id; final StatisticType type; final List scopes; final Timeframe? timeframe; @@ -12,8 +14,14 @@ class Statistic { Statistic({ required this.type, required this.scopes, + String? id, this.timeframe, this.selectedGroups, this.selectedGames, - }); + }) : id = id ?? const Uuid().v4(); + + @override + String toString() { + return 'Statistic(id: $id, type: $type, scopes: $scopes, timeframe: $timeframe, selectedGroups: $selectedGroups, selectedGames: $selectedGames)'; + } } diff --git a/lib/presentation/views/main_menu/statistics_view/create_statistic_view.dart b/lib/presentation/views/main_menu/statistics_view/create_statistic_view.dart index 17706a1..9ac03aa 100644 --- a/lib/presentation/views/main_menu/statistics_view/create_statistic_view.dart +++ b/lib/presentation/views/main_menu/statistics_view/create_statistic_view.dart @@ -571,8 +571,8 @@ class _CreateStatisticViewState extends State { selectedGroups: selectedGroups, selectedGames: selectedGames, ); - // final db = Provider.of(context, listen: false); - // db.statisticDao.addStatistic(newStatistic); + final db = Provider.of(context, listen: false); + db.statisticDao.addStatistic(statistic: newStatistic); Navigator.of(context).pop(newStatistic); } } diff --git a/lib/presentation/views/main_menu/statistics_view/statistics_view.dart b/lib/presentation/views/main_menu/statistics_view/statistics_view.dart index 3470a12..f551a8b 100644 --- a/lib/presentation/views/main_menu/statistics_view/statistics_view.dart +++ b/lib/presentation/views/main_menu/statistics_view/statistics_view.dart @@ -5,13 +5,12 @@ import 'package:tallee/core/constants.dart'; import 'package:tallee/data/db/database.dart'; import 'package:tallee/data/models/match.dart'; import 'package:tallee/data/models/player.dart'; +import 'package:tallee/data/models/statistic.dart'; import 'package:tallee/l10n/generated/app_localizations.dart'; import 'package:tallee/presentation/views/main_menu/statistics_view/create_statistic_view.dart'; import 'package:tallee/presentation/widgets/app_skeleton.dart'; import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart'; -import 'package:tallee/presentation/widgets/tiles/quick_info_tile.dart'; -import 'package:tallee/presentation/widgets/tiles/statistics_tile.dart'; -import 'package:tallee/presentation/widgets/top_centered_message.dart'; +import 'package:tallee/presentation/widgets/tiles/info_tile.dart'; class StatisticsView extends StatefulWidget { /// A view that displays player statistics @@ -38,11 +37,20 @@ class _StatisticsViewState extends State { 1, )); bool isLoading = true; + List statisticTiles = List.generate( + 4, + (_) => const InfoTile( + icon: Icons.sports_score, + title: 'Skeleton Statistic', + width: double.infinity, + content: Text('Skeleton content'), + ), + ); @override void initState() { super.initState(); - loadStatisticData(); + getStatisticTiles(context); } @override @@ -51,7 +59,8 @@ class _StatisticsViewState extends State { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return Stack( - alignment: AlignmentDirectional.center, + alignment: AlignmentDirectional.bottomCenter, + fit: StackFit.expand, children: [ SingleChildScrollView( child: AppSkeleton( @@ -62,73 +71,7 @@ class _StatisticsViewState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - QuickInfoTile( - width: constraints.maxWidth * 0.45, - height: constraints.maxHeight * 0.13, - title: loc.matches, - icon: Icons.groups_rounded, - value: matchCount, - ), - SizedBox(width: constraints.maxWidth * 0.05), - QuickInfoTile( - width: constraints.maxWidth * 0.45, - height: constraints.maxHeight * 0.13, - title: loc.groups, - icon: Icons.groups_rounded, - value: groupCount, - ), - ], - ), - SizedBox(height: constraints.maxHeight * 0.02), - Visibility( - visible: - winCounts.isEmpty && - matchCounts.isEmpty && - winRates.isEmpty, - replacement: Column( - children: [ - StatisticsTile( - icon: Icons.sports_score, - title: loc.wins, - width: constraints.maxWidth * 0.95, - values: winCounts, - itemCount: 3, - barColor: Colors.green, - ), - SizedBox(height: constraints.maxHeight * 0.02), - StatisticsTile( - icon: Icons.percent, - title: loc.winrate, - width: constraints.maxWidth * 0.95, - values: winRates, - itemCount: 5, - barColor: Colors.orange[700]!, - ), - SizedBox(height: constraints.maxHeight * 0.02), - StatisticsTile( - icon: Icons.casino, - title: loc.amount_of_matches, - width: constraints.maxWidth * 0.95, - values: matchCounts, - itemCount: 10, - barColor: Colors.blue, - ), - ], - ), - child: TopCenteredMessage( - icon: Icons.info, - title: loc.info, - message: AppLocalizations.of( - context, - ).no_statistics_available, - ), - ), - SizedBox(height: MediaQuery.paddingOf(context).bottom), - ], + children: [...statisticTiles], ), ), ), @@ -138,8 +81,8 @@ class _StatisticsViewState extends State { child: MainMenuButton( text: loc.create_statistic, icon: Icons.bar_chart, - onPressed: () { - Navigator.push( + onPressed: () async { + Statistic newStatistic = await Navigator.push( context, adaptivePageRoute( builder: (context) => CreateStatisticView( @@ -147,6 +90,18 @@ class _StatisticsViewState extends State { ), ), ); + final newTile = InfoTile( + icon: Icons.sports_score, + title: newStatistic.type.name, + width: MediaQuery.sizeOf(context).width * 0.95, + content: Text( + '${newStatistic.id}\n${newStatistic.scopes}\n${newStatistic.type}\n${newStatistic.timeframe}\n${newStatistic.selectedGroups}\n${newStatistic.selectedGames}\n', + ), + ); + + setState(() { + statisticTiles.add(newTile); + }); }, ), ), @@ -196,6 +151,30 @@ class _StatisticsViewState extends State { }); } + Future getStatisticTiles(BuildContext context) async { + isLoading = true; + final db = Provider.of(context, listen: false); + final statistics = await db.statisticDao.getAllStatistics(); + + setState(() { + statisticTiles = []; + for (var statistic in statistics) { + statisticTiles.add( + InfoTile( + icon: Icons.sports_score, + title: statistic.type.name, + width: MediaQuery.sizeOf(context).width * 0.95, + content: Text(statistic.toString()), + ), + ); + statisticTiles.add( + SizedBox(height: MediaQuery.sizeOf(context).height * 0.02), + ); + } + }); + isLoading = false; + } + /// Calculates the number of wins for each player /// and returns a sorted list of tuples (playerName, winCount) List<(Player, int)> _calculateWinsForAllPlayers({ diff --git a/pubspec.yaml b/pubspec.yaml index 8ca8550..b6563cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: tallee description: "Tracking App for Card Games" publish_to: 'none' -version: 0.0.33+273 +version: 0.0.33+274 environment: sdk: ^3.8.1 diff --git a/test/db_tests/statistics/statistic_test.dart b/test/db_tests/statistics/statistic_test.dart new file mode 100644 index 0000000..b969b4c --- /dev/null +++ b/test/db_tests/statistics/statistic_test.dart @@ -0,0 +1,124 @@ +import 'dart:core'; + +import 'package:clock/clock.dart'; +import 'package:drift/drift.dart' hide isNotNull; +import 'package:drift/native.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tallee/core/enums.dart'; +import 'package:tallee/data/db/database.dart'; +import 'package:tallee/data/models/game.dart'; +import 'package:tallee/data/models/group.dart'; +import 'package:tallee/data/models/match.dart'; +import 'package:tallee/data/models/player.dart'; +import 'package:tallee/data/models/score_entry.dart'; +import 'package:tallee/data/models/statistic.dart'; + +void main() { + late AppDatabase database; + late Player testPlayer1; + late Player testPlayer2; + late Player testPlayer3; + late Player testPlayer4; + late Player testPlayer5; + late Group testGroup1; + late Group testGroup2; + late Game testGame; + late Match testMatch1; + late Match testMatch2; + late Match testMatchOnlyPlayers; + late Match testMatchOnlyGroup; + final fixedDate = DateTime(2025, 19, 11, 00, 11, 23); + final fakeClock = Clock(() => fixedDate); + + setUp(() async { + database = AppDatabase( + DatabaseConnection( + NativeDatabase.memory(), + // Recommended for widget tests to avoid test errors. + closeStreamsSynchronously: true, + ), + ); + + withClock(fakeClock, () { + testPlayer1 = Player(name: 'Alice'); + testPlayer2 = Player(name: 'Bob'); + testPlayer3 = Player(name: 'Charlie'); + testPlayer4 = Player(name: 'Diana'); + testPlayer5 = Player(name: 'Eve'); + testGroup1 = Group( + name: 'Test Group 1', + 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: GameColor.blue, + icon: '', + ); + testMatch1 = Match( + name: 'First Test Match', + game: testGame, + group: testGroup1, + players: [testPlayer4, testPlayer5], + scores: {testPlayer4.id: ScoreEntry(score: 1)}, + ); + testMatch2 = Match( + name: 'Second Test Match', + game: testGame, + group: testGroup2, + players: [testPlayer1, testPlayer2, testPlayer3], + ); + testMatchOnlyPlayers = Match( + name: 'Test Match with Players', + game: testGame, + players: [testPlayer1, testPlayer2, testPlayer3], + ); + testMatchOnlyGroup = Match( + name: 'Test Match with Group', + game: testGame, + group: testGroup2, + players: testGroup2.members, + ); + }); + await database.playerDao.addPlayersAsList( + players: [ + testPlayer1, + testPlayer2, + testPlayer3, + testPlayer4, + testPlayer5, + ], + ); + await database.groupDao.addGroupsAsList(groups: [testGroup1, testGroup2]); + await database.gameDao.addGame(game: testGame); + }); + tearDown(() async { + await database.close(); + }); + + test('Adding/fetching statistic works correclty', () async { + final statistic = Statistic( + type: StatisticType.averageScore, + scopes: [StatisticScope.allPlayers, StatisticScope.selectedGames], + timeframe: Timeframe.allTime, + selectedGames: [testGame], + selectedGroups: [testGroup1], + ); + + final added = await database.statisticDao.addStatistic( + statistic: statistic, + ); + expect(added, isTrue); + + final fetched = await database.statisticDao.getStatisticById(statistic.id); + expect(fetched, isNotNull); + expect(fetched!.type, statistic.type); + }); +}