feat: statistic detail view
This commit is contained in:
@@ -80,12 +80,13 @@ class StatisticDao extends DatabaseAccessor<AppDatabase>
|
||||
result.map((row) async {
|
||||
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: scopes,
|
||||
timeframe: Timeframe.values.firstWhereOrNull(
|
||||
(t) => t.name == row.timeframe,
|
||||
),
|
||||
|
||||
@@ -12,12 +12,13 @@ class StatisticGameDao extends DatabaseAccessor<AppDatabase>
|
||||
StatisticGameDao(super.db);
|
||||
|
||||
/// Retrieves a list of games associated with a specific statistic.
|
||||
Future<List<Game>> getGamesForStatistic(String statisticId) async {
|
||||
Future<List<Game>?> 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();
|
||||
if (results.isEmpty) return null;
|
||||
return results
|
||||
.map(
|
||||
(row) => Game(
|
||||
|
||||
@@ -12,7 +12,7 @@ class StatisticGroupDao extends DatabaseAccessor<AppDatabase>
|
||||
StatisticGroupDao(super.db);
|
||||
|
||||
/// Retrieves a list of groups associated with a specific statistic.
|
||||
Future<List<Group>> getGroupsForStatistic(String statisticId) async {
|
||||
Future<List<Group>?> getGroupsForStatistic(String statisticId) async {
|
||||
final query = select(statisticGroupTable).join([
|
||||
innerJoin(
|
||||
groupTable,
|
||||
@@ -21,6 +21,7 @@ class StatisticGroupDao extends DatabaseAccessor<AppDatabase>
|
||||
])..where(statisticGroupTable.statisticId.equals(statisticId));
|
||||
|
||||
final results = await query.map((row) => row.readTable(groupTable)).get();
|
||||
if (results.isEmpty) return null;
|
||||
final groups = await Future.wait(
|
||||
results.map((result) async {
|
||||
final groupMembers = await db.playerGroupDao.getPlayersOfGroup(
|
||||
|
||||
@@ -15,8 +15,8 @@ class StatisticScopeDao extends DatabaseAccessor<AppDatabase>
|
||||
final query = select(statisticScopeTable)
|
||||
..where((tbl) => tbl.statisticId.equals(statisticId));
|
||||
|
||||
final results = await query.get();
|
||||
return results
|
||||
final result = await query.get();
|
||||
return result
|
||||
.map(
|
||||
(row) => StatisticScope.values.firstWhere(
|
||||
(e) => e.name == row.scope,
|
||||
|
||||
Reference in New Issue
Block a user