From 68df5319dfc80a6c43c4624fde7b76d5db347f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Fri, 29 Sep 2023 21:16:39 +0100 Subject: [PATCH 1/3] fix: parsing for half duration lectures --- uni/lib/controller/parsers/parser_schedule.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uni/lib/controller/parsers/parser_schedule.dart b/uni/lib/controller/parsers/parser_schedule.dart index 2a98c4853..80981e878 100644 --- a/uni/lib/controller/parsers/parser_schedule.dart +++ b/uni/lib/controller/parsers/parser_schedule.dart @@ -35,7 +35,11 @@ Future> parseSchedule(http.Response response) async { // 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; + 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; From 8f4465cf88968f798d0830ffd8180ca6a785b5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Fri, 29 Sep 2023 21:18:25 +0100 Subject: [PATCH 2/3] docs: update comment on api parsing for lectures --- uni/lib/controller/parsers/parser_schedule.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/uni/lib/controller/parsers/parser_schedule.dart b/uni/lib/controller/parsers/parser_schedule.dart index 80981e878..34aacac79 100644 --- a/uni/lib/controller/parsers/parser_schedule.dart +++ b/uni/lib/controller/parsers/parser_schedule.dart @@ -32,9 +32,10 @@ Future> 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. + + // Note: aula_duracao returns 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() From ba664720dc7bc31921a9f779d691e8dd82e45e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Fri, 29 Sep 2023 21:31:42 +0100 Subject: [PATCH 3/3] style: format files --- uni/lib/controller/parsers/parser_schedule.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/uni/lib/controller/parsers/parser_schedule.dart b/uni/lib/controller/parsers/parser_schedule.dart index 34aacac79..0a950c7d0 100644 --- a/uni/lib/controller/parsers/parser_schedule.dart +++ b/uni/lib/controller/parsers/parser_schedule.dart @@ -32,14 +32,14 @@ Future> 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; - - // Note: aula_duracao returns an integer when the lecture is 1 hour long + + // 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. + // 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; + ? (lectureDuration * 2).toInt() + : (lectureDuration as int) * 2; final room = (lecture['sala_sigla'] as String).replaceAll(RegExp(r'\+'), '\n');