Skip to content

Commit

Permalink
Update fetchSheet to handle only 200 responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano-7 committed Dec 30, 2024
1 parent c73b2ce commit 3cd50d8
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ class CourseUnitsInfoFetcher implements SessionDependantFetcher {
url,
{'pv_ocorrencia_id': occurId.toString()},
session,
),
).catchError((_) => Response('', 500)),
),
);

final bestResponse = responses.fold<Response?>(
null,
(best, current) =>
current.body.length > (best?.body.length ?? 0) ? current : best,
);
final bestResponse = responses
.where((response) => response.statusCode == 200)
.fold<Response?>(
null,
(best, current) =>
current.body.length > (best?.body.length ?? 0) ? current : best,
);

return bestResponse != null
? parseSheet(bestResponse)
Expand Down

0 comments on commit 3cd50d8

Please sign in to comment.