unify pipeline, load friends leaderboard from homepage data
Some checks failed
Release / meta (push) Successful in 10s
Release / linux-build (push) Successful in 57s
Release / web-build (push) Failing after 1m11s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Release / android-build (push) Has been cancelled

This commit is contained in:
2026-01-03 22:55:03 +00:00
parent 23f294c6f0
commit 196511dfab
6 changed files with 106 additions and 145 deletions

View File

@@ -350,6 +350,7 @@ class HomepageStats {
final List<YearlyMileage> yearlyMileage;
final List<LocoSummary> topLocos;
final List<LeaderboardEntry> leaderboard;
final List<LeaderboardEntry> friendsLeaderboard;
final List<TripSummary> trips;
final int legCount;
final UserData? user;
@@ -359,6 +360,7 @@ class HomepageStats {
required this.yearlyMileage,
required this.topLocos,
required this.leaderboard,
required this.friendsLeaderboard,
required this.trips,
required this.legCount,
this.user,
@@ -370,6 +372,17 @@ class HomepageStats {
final totalMileage = mileageData is Map && mileageData['mileage'] != null
? (mileageData['mileage'] as num).toDouble()
: 0.0;
List<LeaderboardEntry> parseLeaderboard(dynamic raw) {
if (raw is List) {
return raw
.whereType<Map>()
.map((e) => LeaderboardEntry.fromJson(
e.map((k, v) => MapEntry(k.toString(), v)),
))
.toList();
}
return const [];
}
return HomepageStats(
totalMileage: totalMileage,
yearlyMileage: (json['yearly_mileage'] as List? ?? [])
@@ -378,9 +391,9 @@ class HomepageStats {
topLocos: (json['top_locos'] as List? ?? [])
.map((e) => LocoSummary.fromJson(e))
.toList(),
leaderboard: (json['leaderboard_data'] as List? ?? [])
.map((e) => LeaderboardEntry.fromJson(e))
.toList(),
leaderboard: parseLeaderboard(json['leaderboard_data'] ?? json['leaderboard']),
friendsLeaderboard:
parseLeaderboard(json['friends_leaderboard'] ?? json['friendsLeaderboard']),
trips: (json['trip_data'] as List? ?? [])
.map((e) => TripSummary.fromJson(e))
.toList(),