Skip to content

Commit

Permalink
Hotfix/api parsing for half duration lectures (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes authored Sep 29, 2023
2 parents 36edab7 + ba66472 commit 7558258
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions uni/lib/controller/parsers/parser_schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ Future<List<Lecture>> parseSchedule(http.Response response) async {
final secBegin = lecture['hora_inicio'] as int;
final subject = lecture['ucurr_sigla'] as String;
final typeClass = lecture['tipo'] as String;
// TODO(luisd): this was marked as a double on the develop branch but the
// tests' example api returns an integer. At the moment there are no
// classes so I can't test this.
final blocks = (lecture['aula_duracao'] as int) * 2;

// Note: aula_duracao is an integer when the lecture is 1 hour long
// or 2 hours long and so on. When the lecture is 1.5 hours long, it
// returns a double, with the value 1.5.
final lectureDuration = lecture['aula_duracao'];
final blocks = lectureDuration is double
? (lectureDuration * 2).toInt()
: (lectureDuration as int) * 2;

final room =
(lecture['sala_sigla'] as String).replaceAll(RegExp(r'\+'), '\n');
final teacher = lecture['doc_sigla'] as String;
Expand Down

0 comments on commit 7558258

Please sign in to comment.