Skip to content

Commit

Permalink
[race hub] fix documents parsing; fix info button
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Jun 25, 2024
1 parent 2dbab84 commit a3cb853
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/Screens/racehub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class RaceHubScreen extends StatelessWidget {
elevation: 5,
child: ListTile(
title: Text(
snapshot.data?[index - 1].name ?? '',
snapshot.data![index - 1].name,
),
subtitle: Text(
'Published on ${snapshot.data?[index - 1].postedDate}',
snapshot.data![index - 1].postedDate,
style: TextStyle(
fontSize: 12,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/convert_ergast_and_formula_one.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class Convert {
"qatar": '1251',
"united_arab_emirates": '1252',
};
return ergastToFormulaOne[circuitId];
return ergastToFormulaOne[circuitId.toLowerCase()];
}

String circuitNameFromFormulaOneToRoundNumber(String circuitId) {
Expand Down
27 changes: 8 additions & 19 deletions lib/scraping/fia.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,14 @@ class FIAScraper {
List<dom.Element> tempResult = document
.getElementsByClassName('event-wrapper')[0]
.getElementsByClassName('document-row');
for (var document in tempResult) {
if (document.firstChild!.nodeType == 3) {
documents.add(
SessionDocument(
'This document cannot be parsed.',
'none',
'https://www.fia.com/documents/championships/fia-formula-one-world-championship-14/season/season-2024-2043',
),
);
} else {
documents.add(
SessionDocument(
document.firstChild!.children[1].text.substring(
13, document.firstChild!.children[1].text.length - 3),
document.firstChild!.children[2].children[0].text,
'https://www.fia.com${document.firstChild?.attributes['href']}',
),
);
}
for (dom.Element document in tempResult) {
documents.add(
SessionDocument(
document.getElementsByClassName('title').first.text.trim(),
document.getElementsByClassName('published').first.text.trim(),
'https://www.fia.com${document.getElementsByTagName('a').first.attributes['href']}',
),
);
}
return documents;
}
Expand Down

0 comments on commit a3cb853

Please sign in to comment.