Skip to content

Commit

Permalink
[racehub] fix sprint-related results; show yellow dns in qualifs
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Oct 23, 2024
1 parent 0c597b8 commit 5f76c6b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 24 deletions.
24 changes: 18 additions & 6 deletions lib/Screens/race_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,15 @@ class _RaceResultsProviderState extends State<RaceResultsProvider> {
Future<List<DriverResult>> getRaceStandingsFromApi({
Race? race,
String? meetingId,
String? raceUrl,
}) async {
if (meetingId != null) {
if (meetingId != null && raceUrl != null) {
// starting to do like official api devs...
return await Formula1().getRaceStandings(meetingId, '66666');
if (raceUrl == 'race') {
return await Formula1().getRaceStandings(meetingId, '66666');
} else {
return await Formula1().getSprintStandings(meetingId);
}
} else {
bool useOfficialDataSoure = Hive.box('settings')
.get('useOfficialDataSoure', defaultValue: false) as bool;
Expand Down Expand Up @@ -676,7 +681,12 @@ class _RaceResultsProviderState extends State<RaceResultsProvider> {
return raceUrl != ''
? FutureBuilder<List<DriverResult>>(
future: championship == 'Formula 1'
? getRaceStandingsFromApi(meetingId: raceUrl.split('/')[7])
? getRaceStandingsFromApi(
meetingId: raceUrl.startsWith('http')
? raceUrl.split('/')[7]
: widget.raceId,
raceUrl: raceUrl,
)
: getRaceStandingsFromFE(widget.raceId!, raceUrl),
builder: (context, snapshot) {
if (snapshot.hasError) {
Expand Down Expand Up @@ -871,12 +881,12 @@ class _SprintResultsProviderState extends State<SprintResultsProvider> {
}) async {
if (meetingId != null) {
// same as race results...
return await Formula1().getSprintStandings(meetingId, '66666');
return await Formula1().getSprintStandings(meetingId);
} else {
bool useOfficialDataSoure = Hive.box('settings')
.get('useOfficialDataSoure', defaultValue: false) as bool;
if (useOfficialDataSoure) {
return await Formula1().getSprintStandings(race!.meetingId, race.round);
return await Formula1().getSprintStandings(race!.meetingId);
} else {
return await ErgastApi().getSprintStandings(race!.round);
}
Expand Down Expand Up @@ -1054,7 +1064,9 @@ class _QualificationResultsProviderState
: FutureBuilder<List>(
future: widget.raceUrl != null
? getQualificationStandings(
meetingId: widget.raceUrl!.split('/')[7],
meetingId: widget.raceUrl!.startsWith('http')
? widget.raceUrl!.split('/')[7]
: widget.sessionId,
)
: getQualificationStandings(
race: widget.race!,
Expand Down
28 changes: 15 additions & 13 deletions lib/Screens/session_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,28 @@ class _SessionScreenState extends State<SessionScreen> {
? RaceResultsProvider(
raceUrl: championship == 'Formula 1'
? widget.session.sessionsAbbreviation == 'r'
? widget.session.baseUrl.replaceAll(
'session-type', 'race-result')
: widget.session.baseUrl.replaceAll(
'session-type',
'sprint-results',
)
? 'race'
: 'sprint-results'
: widget.session.baseUrl,
raceId: widget.meetingId,
)
: championship == 'Formula 1'
? QualificationResultsProvider(
raceUrl: championship == 'Formula 1'
? widget.session.baseUrl.replaceAll(
'session-type',
widget.session.sessionsAbbreviation ==
'ss'
? 'sprint-qualifying'
: 'qualifying',
)
? widget.session.sessionsAbbreviation ==
'ss'
? 'sprint-qualifying'
: 'qualifying'
: widget.session.baseUrl,
sessionId: widget.meetingId,
hasSprint:
widget.session.sessionsAbbreviation == 'ss'
? true
: false,
isSprintQualifying:
widget.session.sessionsAbbreviation == 'ss'
? true
: false,
)
: FreePracticeResultsProvider(
widget.sessionFullName,
Expand Down
3 changes: 1 addition & 2 deletions lib/api/formula1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ class Formula1 {
}
}

FutureOr<List<DriverResult>> getSprintStandings(
String meetingId, String session) async {
FutureOr<List<DriverResult>> getSprintStandings(String meetingId) async {
List<DriverResult> driversResults = [];
String time;
String endpoint = Hive.box('settings')
Expand Down
6 changes: 3 additions & 3 deletions lib/helpers/driver_result_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class QualificationResultsItem extends StatelessWidget {
color: winningTimeQOne == item.timeq1
? Colors.white
: item.timeq1 != '--'
? item.timeq1 == 'DNF'
? item.timeq1 == 'DNF' || item.timeq1 == 'DNS'
? Colors.yellow
: const Color(0xff00ff00)
: Colors.white,
Expand Down Expand Up @@ -531,7 +531,7 @@ class QualificationResultsItem extends StatelessWidget {
color: winningTimeQTwo == item.timeq2
? Colors.white
: item.timeq2 != '--'
? item.timeq2 == 'DNF'
? item.timeq2 == 'DNF' || item.timeq2 == 'DNS'
? Colors.yellow
: const Color(0xff00ff00)
: Colors.white,
Expand Down Expand Up @@ -575,7 +575,7 @@ class QualificationResultsItem extends StatelessWidget {
color: index == 0
? Colors.white
: item.timeq3 != '--'
? item.timeq3 == 'DNF'
? item.timeq3 == 'DNF' || item.timeq3 == 'DNS'
? Colors.yellow
: const Color(0xff00ff00)
: Colors.white,
Expand Down

0 comments on commit 5f76c6b

Please sign in to comment.