From c2ebca73ba15419b3c830b9277198f2dcd84f825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Sat, 30 Nov 2024 18:27:10 +0000 Subject: [PATCH 1/2] fix: no exams in mobility --- packages/uni_app/lib/controller/fetchers/exam_fetcher.dart | 4 ++++ .../local_storage/database/app_courses_database.dart | 2 +- packages/uni_app/lib/controller/parsers/parser_courses.dart | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart index 8d79b3ece..fbc8569f6 100644 --- a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart +++ b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart @@ -26,6 +26,10 @@ class ExamFetcher implements SessionDependantFetcher { var courseExams = {}; final urls = getEndpoints(session); for (final course in courses) { + if (course.id == null) { + continue; + } + for (final url in urls) { final currentCourseExams = await parserExams.parseExams( await NetworkRouter.getWithCookies( diff --git a/packages/uni_app/lib/controller/local_storage/database/app_courses_database.dart b/packages/uni_app/lib/controller/local_storage/database/app_courses_database.dart index 53cf51f85..cbc5e4b1d 100644 --- a/packages/uni_app/lib/controller/local_storage/database/app_courses_database.dart +++ b/packages/uni_app/lib/controller/local_storage/database/app_courses_database.dart @@ -24,7 +24,7 @@ class AppCoursesDatabase extends AppDatabase> { // Convert the List into a List. return List.generate(maps.length, (i) { return Course( - id: maps[i]['cur_id'] as int? ?? 0, + id: maps[i]['cur_id'] as int?, festId: maps[i]['fest_id'] as int? ?? 0, name: maps[i]['cur_nome'] as String?, abbreviation: maps[i]['abbreviation'] as String?, diff --git a/packages/uni_app/lib/controller/parsers/parser_courses.dart b/packages/uni_app/lib/controller/parsers/parser_courses.dart index 8e84304e3..63be1040d 100644 --- a/packages/uni_app/lib/controller/parsers/parser_courses.dart +++ b/packages/uni_app/lib/controller/parsers/parser_courses.dart @@ -39,7 +39,7 @@ List _parseCourses(http.Response response) { courses.add( Course( faculty: faculty, - id: int.parse(courseId ?? '0'), + id: courseId != null ? int.parse(courseId) : null, state: courseState, name: courseName ?? '', festId: int.parse(courseFestId ?? '0'), @@ -66,7 +66,7 @@ List _parseCourses(http.Response response) { Course( firstEnrollment: int.parse(courseFirstEnrollment), faculty: faculty, - id: int.parse(courseId ?? '0'), + id: courseId != null ? int.parse(courseId) : null, state: courseState, name: courseName ?? '', festId: int.parse(courseFestId ?? '0'), From 4d0205b624b8589bf4d684db795cd3a115ef504f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Sat, 30 Nov 2024 18:35:28 +0000 Subject: [PATCH 2/2] style: format code --- packages/uni_app/lib/controller/fetchers/exam_fetcher.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart index fbc8569f6..6a45bd341 100644 --- a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart +++ b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart @@ -29,7 +29,7 @@ class ExamFetcher implements SessionDependantFetcher { if (course.id == null) { continue; } - + for (final url in urls) { final currentCourseExams = await parserExams.parseExams( await NetworkRouter.getWithCookies(