diff --git a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart index 8d79b3ece..036393455 100644 --- a/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart +++ b/packages/uni_app/lib/controller/fetchers/exam_fetcher.dart @@ -47,7 +47,7 @@ class ExamFetcher implements SessionDependantFetcher { ) && courseExam.examType != 'EE' && courseExam.examType != 'EAE' && - courseExam.subject == uc.abbreviation && + courseExam.subjectAcronym == uc.abbreviation && uc.enrollmentIsValid() && !courseExam.hasEnded()) { exams.add(courseExam); diff --git a/packages/uni_app/lib/controller/local_storage/database/app_exams_database.dart b/packages/uni_app/lib/controller/local_storage/database/app_exams_database.dart index b628ddcf0..c087a05e3 100644 --- a/packages/uni_app/lib/controller/local_storage/database/app_exams_database.dart +++ b/packages/uni_app/lib/controller/local_storage/database/app_exams_database.dart @@ -10,10 +10,10 @@ import 'package:uni/model/entities/exam.dart'; /// See the [Exam] class to see what data is stored in this database. class AppExamsDatabase extends AppDatabase> { AppExamsDatabase() - : super('exams.db', [_createScript], onUpgrade: migrate, version: 7); + : super('exams.db', [_createScript], onUpgrade: migrate, version: 8); static const _createScript = ''' -CREATE TABLE exams(id TEXT, subject TEXT, start TEXT, finish TEXT, +CREATE TABLE exams(id TEXT, subjectAcronym TEXT, subject TEXT, start TEXT, finish TEXT, rooms TEXT, examType TEXT, faculty TEXT, PRIMARY KEY (id,faculty)) '''; /// Returns a list containing all of the exams stored in this database. @@ -24,6 +24,7 @@ CREATE TABLE exams(id TEXT, subject TEXT, start TEXT, finish TEXT, return List.generate(maps.length, (i) { return Exam.secConstructor( maps[i]['id'] as String, + maps[i]['subjectAcronym'] as String, maps[i]['subject'] as String, DateTime.parse(maps[i]['start'] as String), DateTime.parse(maps[i]['finish'] as String), diff --git a/packages/uni_app/lib/controller/parsers/parser_exams.dart b/packages/uni_app/lib/controller/parsers/parser_exams.dart index 8069410a6..99a04cb6c 100644 --- a/packages/uni_app/lib/controller/parsers/parser_exams.dart +++ b/packages/uni_app/lib/controller/parsers/parser_exams.dart @@ -27,6 +27,7 @@ class ParserExams { final dates = []; final examTypes = []; var rooms = []; + String? subjectAcronym; String? subject; var id = '0'; var days = 0; @@ -46,7 +47,8 @@ class ParserExams { if (exams.querySelector('td.exame') != null) { exams.querySelectorAll('td.exame').forEach((examsDay) { if (examsDay.querySelector('a') != null) { - subject = examsDay.querySelector('a')!.text; + subjectAcronym = examsDay.querySelector('a')!.text; + subject = examsDay.querySelector('a')!.attributes['title']; id = Uri.parse(examsDay.querySelector('a')!.attributes['href']!) .queryParameters['p_exa_id']!; } @@ -73,6 +75,7 @@ class ParserExams { id, begin, end, + subjectAcronym ?? '', subject ?? '', rooms, examTypes[tableNum], diff --git a/packages/uni_app/lib/generated/controller/parsers/schedule/new_api/models/response_lecture_unit.g.dart b/packages/uni_app/lib/generated/controller/parsers/schedule/new_api/models/response_lecture_unit.g.dart index 1d1ba95b8..6844ccc8a 100644 --- a/packages/uni_app/lib/generated/controller/parsers/schedule/new_api/models/response_lecture_unit.g.dart +++ b/packages/uni_app/lib/generated/controller/parsers/schedule/new_api/models/response_lecture_unit.g.dart @@ -9,7 +9,7 @@ part of '../../../../../../controller/parsers/schedule/new_api/models/response_l ResponseLectureUnit _$ResponseLectureUnitFromJson(Map json) => ResponseLectureUnit( json['acronym'] as String, - json['sigarra_id'] as int, + (json['sigarra_id'] as num).toInt(), ); Map _$ResponseLectureUnitToJson( diff --git a/packages/uni_app/lib/generated/model/entities/course.g.dart b/packages/uni_app/lib/generated/model/entities/course.g.dart index d51524b13..a2b3fd763 100644 --- a/packages/uni_app/lib/generated/model/entities/course.g.dart +++ b/packages/uni_app/lib/generated/model/entities/course.g.dart @@ -8,7 +8,7 @@ part of '../../../model/entities/course.dart'; Map _$CourseToJson(Course instance) => { 'cur_id': instance.id, - 'fest_id ': instance.festId, + 'fest_id': instance.festId, 'cur_nome': instance.name, 'abbreviation': instance.abbreviation, 'ano_curricular': instance.currYear, diff --git a/packages/uni_app/lib/generated/model/entities/course_units/course_unit.g.dart b/packages/uni_app/lib/generated/model/entities/course_units/course_unit.g.dart index dba0cfd22..17c5b0503 100644 --- a/packages/uni_app/lib/generated/model/entities/course_units/course_unit.g.dart +++ b/packages/uni_app/lib/generated/model/entities/course_units/course_unit.g.dart @@ -9,10 +9,10 @@ part of '../../../../model/entities/course_units/course_unit.dart'; CourseUnit _$CourseUnitFromJson(Map json) => CourseUnit( abbreviation: json['ucurr_sigla'] as String, name: json['ucurr_nome'] as String, - occurrId: json['ocorr_id'] as int?, - id: json['ucurr_id'] as int? ?? 0, + occurrId: (json['ocorr_id'] as num?)?.toInt(), + id: (json['ucurr_id'] as num?)?.toInt() ?? 0, code: json['ucurr_codigo'] as String? ?? '', - curricularYear: json['ano'] as int?, + curricularYear: (json['ano'] as num?)?.toInt(), semesterCode: json['per_codigo'] as String?, semesterName: json['per_nome'] as String?, type: json['tipo'] as String?, diff --git a/packages/uni_app/lib/generated/model/entities/exam.g.dart b/packages/uni_app/lib/generated/model/entities/exam.g.dart index 837cd7646..096f779eb 100644 --- a/packages/uni_app/lib/generated/model/entities/exam.g.dart +++ b/packages/uni_app/lib/generated/model/entities/exam.g.dart @@ -10,6 +10,7 @@ Exam _$ExamFromJson(Map json) => Exam( json['id'] as String, const DateTimeConverter().fromJson(json['start'] as String), const DateTimeConverter().fromJson(json['finish'] as String), + json['subjectAcronym'] as String, json['subject'] as String, (json['rooms'] as List).map((e) => e as String).toList(), json['examType'] as String, @@ -20,6 +21,7 @@ Map _$ExamToJson(Exam instance) => { 'start': const DateTimeConverter().toJson(instance.start), 'finish': const DateTimeConverter().toJson(instance.finish), 'id': instance.id, + 'subjectAcronym': instance.subjectAcronym, 'subject': instance.subject, 'rooms': instance.rooms, 'examType': instance.examType, diff --git a/packages/uni_app/lib/generated/model/entities/lecture.g.dart b/packages/uni_app/lib/generated/model/entities/lecture.g.dart index 66a4c44aa..fcc77c8ad 100644 --- a/packages/uni_app/lib/generated/model/entities/lecture.g.dart +++ b/packages/uni_app/lib/generated/model/entities/lecture.g.dart @@ -14,7 +14,7 @@ Lecture _$LectureFromJson(Map json) => Lecture( json['room'] as String, json['teacher'] as String, json['classNumber'] as String, - json['occurrId'] as int, + (json['occurrId'] as num).toInt(), ); Map _$LectureToJson(Lecture instance) => { diff --git a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart index fe8e7e4bb..4cd1c67ee 100644 --- a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart +++ b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart @@ -8,8 +8,8 @@ part of '../../../model/entities/library_occupation.dart'; LibraryOccupation _$LibraryOccupationFromJson(Map json) => LibraryOccupation( - json['occupation'] as int, - json['capacity'] as int, + (json['occupation'] as num).toInt(), + (json['capacity'] as num).toInt(), )..floors = (json['floors'] as List) .map((e) => FloorOccupation.fromJson(e as Map)) .toList(); @@ -23,9 +23,9 @@ Map _$LibraryOccupationToJson(LibraryOccupation instance) => FloorOccupation _$FloorOccupationFromJson(Map json) => FloorOccupation( - json['number'] as int, - json['occupation'] as int, - json['capacity'] as int, + (json['number'] as num).toInt(), + (json['occupation'] as num).toInt(), + (json['capacity'] as num).toInt(), ); Map _$FloorOccupationToJson(FloorOccupation instance) => diff --git a/packages/uni_app/lib/generated/model/entities/location_group.g.dart b/packages/uni_app/lib/generated/model/entities/location_group.g.dart index 4ca96e363..beb8245d1 100644 --- a/packages/uni_app/lib/generated/model/entities/location_group.g.dart +++ b/packages/uni_app/lib/generated/model/entities/location_group.g.dart @@ -10,7 +10,7 @@ LocationGroup _$LocationGroupFromJson(Map json) => LocationGroup( LatLng.fromJson(json['latlng'] as Map), isFloorless: json['isFloorless'] as bool? ?? false, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), ); Map _$LocationGroupToJson(LocationGroup instance) => diff --git a/packages/uni_app/lib/generated/model/entities/reference.g.dart b/packages/uni_app/lib/generated/model/entities/reference.g.dart index 53b2a3150..6778cd83b 100644 --- a/packages/uni_app/lib/generated/model/entities/reference.g.dart +++ b/packages/uni_app/lib/generated/model/entities/reference.g.dart @@ -9,8 +9,8 @@ part of '../../../model/entities/reference.dart'; Reference _$ReferenceFromJson(Map json) => Reference( json['description'] as String, const DateTimeConverter().fromJson(json['limitDate'] as String), - json['entity'] as int, - json['reference'] as int, + (json['entity'] as num).toInt(), + (json['reference'] as num).toInt(), (json['amount'] as num).toDouble(), ); diff --git a/packages/uni_app/lib/generated/model/entities/restaurant.g.dart b/packages/uni_app/lib/generated/model/entities/restaurant.g.dart index 5471eb4f0..bd3f3be3b 100644 --- a/packages/uni_app/lib/generated/model/entities/restaurant.g.dart +++ b/packages/uni_app/lib/generated/model/entities/restaurant.g.dart @@ -7,7 +7,7 @@ part of '../../../model/entities/restaurant.dart'; // ************************************************************************** Restaurant _$RestaurantFromJson(Map json) => Restaurant( - json['id'] as int?, + (json['id'] as num?)?.toInt(), json['name'] as String, json['ref'] as String, meals: (json['meals'] as List) diff --git a/packages/uni_app/lib/generated/model/entities/trip.g.dart b/packages/uni_app/lib/generated/model/entities/trip.g.dart index 973f9d436..bdf83bd20 100644 --- a/packages/uni_app/lib/generated/model/entities/trip.g.dart +++ b/packages/uni_app/lib/generated/model/entities/trip.g.dart @@ -9,7 +9,7 @@ part of '../../../model/entities/trip.dart'; Trip _$TripFromJson(Map json) => Trip( line: json['line'] as String, destination: json['destination'] as String, - timeRemaining: json['timeRemaining'] as int, + timeRemaining: (json['timeRemaining'] as num).toInt(), ); Map _$TripToJson(Trip instance) => { diff --git a/packages/uni_app/lib/model/entities/exam.dart b/packages/uni_app/lib/model/entities/exam.dart index 280661e2d..5f7a5a24c 100644 --- a/packages/uni_app/lib/model/entities/exam.dart +++ b/packages/uni_app/lib/model/entities/exam.dart @@ -21,6 +21,7 @@ class Exam { this.id, this.start, this.finish, + this.subjectAcronym, this.subject, this.rooms, this.examType, @@ -31,6 +32,7 @@ class Exam { Exam.secConstructor( this.id, + this.subjectAcronym, this.subject, this.start, this.finish, @@ -42,6 +44,7 @@ class Exam { final DateTime start; final DateTime finish; final String id; + final String subjectAcronym; final String subject; final List rooms; final String examType; @@ -81,7 +84,7 @@ class Exam { @override String toString() { - return '''$id - $subject - ${start.year} - $month - ${start.day} - $startTime-$finishTime - $examType - $rooms - $weekDay'''; + return '''$id - $subjectAcronym - ${start.year} - $month - ${start.day} - $startTime-$finishTime - $examType - $rooms - $weekDay'''; } /// Prints the data in this exam to the [Logger] with an INFO level. @@ -92,7 +95,7 @@ class Exam { @override bool operator ==(Object other) => identical(this, other) || - other is Exam && id == other.id && subject == other.subject; + other is Exam && id == other.id && subjectAcronym == other.subjectAcronym; @override int get hashCode => id.hashCode; diff --git a/packages/uni_app/lib/view/academic_path/exam_page.dart b/packages/uni_app/lib/view/academic_path/exam_page.dart index 7d541697a..f0a996e91 100644 --- a/packages/uni_app/lib/view/academic_path/exam_page.dart +++ b/packages/uni_app/lib/view/academic_path/exam_page.dart @@ -63,7 +63,6 @@ class _ExamsPageState extends State { physics: const NeverScrollableScrollPhysics(), itemCount: entry.value.length, prototypeItem: const ExamCard( - //TODO(thePeras): Solve this at parser level name: 'Computer Laboratory', acronym: 'LCOM', rooms: ['B315', 'B224', 'B207'], @@ -73,8 +72,8 @@ class _ExamsPageState extends State { itemBuilder: (context, index) { final exam = entry.value[index]; return ExamCard( - name: 'Subject Name', - acronym: exam.subject, + name: exam.subject, + acronym: exam.subjectAcronym, //TODO(thePeras): Solve this at parser level rooms: exam.rooms.where((room) => room.isNotEmpty).toList(), type: exam.examType, diff --git a/packages/uni_app/lib/view/exams/widgets/exam_row.dart b/packages/uni_app/lib/view/exams/widgets/exam_row.dart index abacd5686..1a21e7e70 100644 --- a/packages/uni_app/lib/view/exams/widgets/exam_row.dart +++ b/packages/uni_app/lib/view/exams/widgets/exam_row.dart @@ -39,7 +39,7 @@ class _ExamRowState extends State { @override Widget build(BuildContext context) { final roomsKey = - '${widget.exam.subject}-${widget.exam.rooms}-${widget.exam.startTime}-' + '${widget.exam.subjectAcronym}-${widget.exam.rooms}-${widget.exam.startTime}-' '${widget.exam.finishTime}'; return Center( child: Container( @@ -63,7 +63,7 @@ class _ExamRowState extends State { : [], ), ExamTitle( - subject: widget.exam.subject, + subject: widget.exam.subjectAcronym, type: widget.exam.examType, ), Row( @@ -144,7 +144,7 @@ class _ExamRowState extends State { Event createExamEvent() { return Event( - title: '${widget.exam.examType} ${widget.exam.subject}', + title: '${widget.exam.examType} ${widget.exam.subjectAcronym}', location: widget.exam.rooms.toString(), startDate: widget.exam.start, endDate: widget.exam.finish, diff --git a/packages/uni_app/lib/view/home/widgets/remaining_exams_card.dart b/packages/uni_app/lib/view/home/widgets/remaining_exams_card.dart index 56f1f0180..37e4526e3 100644 --- a/packages/uni_app/lib/view/home/widgets/remaining_exams_card.dart +++ b/packages/uni_app/lib/view/home/widgets/remaining_exams_card.dart @@ -30,7 +30,7 @@ class RemainingExamsWidget extends StatelessWidget { style: Theme.of(context).textTheme.bodyLarge, ), ExamTitle( - subject: exam.subject, + subject: exam.subjectAcronym, type: exam.examType, reverseOrder: true, ), diff --git a/packages/uni_app/test/unit/view/Pages/exams_page_view_test.dart b/packages/uni_app/test/unit/view/Pages/exams_page_view_test.dart index 81555ec7c..892680059 100644 --- a/packages/uni_app/test/unit/view/Pages/exams_page_view_test.dart +++ b/packages/uni_app/test/unit/view/Pages/exams_page_view_test.dart @@ -14,9 +14,11 @@ void main() async { await initTestEnvironment(); group('ExamsPage', () { - const firstExamSubject = 'SOPE'; + const firstExamSubjectAcronym = 'SOPE'; + const firstExamSubject = 'Sistemas Operativos'; const firstExamDate = '2019-09-11'; - const secondExamSubject = 'SDIS'; + const secondExamSubjectAcronym = 'SDIS'; + const secondExamSubject = 'Sistemas Distribuídos'; const secondExamDate = '2019-09-12'; testWidgets('When given an empty list', (tester) async { @@ -37,6 +39,7 @@ void main() async { '1230', firstExamBegin, firstExamEnd, + firstExamSubjectAcronym, firstExamSubject, ['B119', 'B107', 'B205'], 'ER', @@ -63,6 +66,7 @@ void main() async { '1231', firstExamBegin, firstExamEnd, + firstExamSubjectAcronym, firstExamSubject, ['B119', 'B107', 'B205'], 'ER', @@ -74,6 +78,7 @@ void main() async { '1232', secondExamBegin, secondExamEnd, + secondExamSubjectAcronym, secondExamSubject, ['B119', 'B107', 'B205'], 'ER', @@ -109,6 +114,7 @@ void main() async { '1233', firstExamBegin, firstExamEnd, + firstExamSubjectAcronym, firstExamSubject, ['B119', 'B107', 'B205'], 'ER', @@ -120,6 +126,7 @@ void main() async { '1234', secondExamBegin, secondExamEnd, + secondExamSubjectAcronym, secondExamSubject, ['B119', 'B107', 'B205'], 'ER', @@ -154,6 +161,7 @@ void main() async { '1235', firstExamBegin, firstExamEnd, + firstExamSubjectAcronym, firstExamSubject, rooms, 'ER', @@ -165,6 +173,7 @@ void main() async { '1236', secondExamBegin, secondExamEnd, + firstExamSubjectAcronym, firstExamSubject, rooms, 'ER', @@ -176,6 +185,7 @@ void main() async { '1237', thirdExamBegin, thirdExamEnd, + secondExamSubjectAcronym, secondExamSubject, rooms, 'ER', @@ -187,6 +197,7 @@ void main() async { '1238', fourthExamBegin, fourthExamEnd, + secondExamSubjectAcronym, secondExamSubject, rooms, 'ER', diff --git a/packages/uni_app/test/unit/view/Widgets/exam_row_test.dart b/packages/uni_app/test/unit/view/Widgets/exam_row_test.dart index be4483997..6b9c1bac3 100644 --- a/packages/uni_app/test/unit/view/Widgets/exam_row_test.dart +++ b/packages/uni_app/test/unit/view/Widgets/exam_row_test.dart @@ -12,7 +12,8 @@ void main() async { await initTestEnvironment(); group('Exam Row', () { - const subject = 'SOPE'; + const subjectAcronym = 'SOPE'; + const subject = 'Sistemas Operativos'; final start = DateTime( DateTime.now().year, DateTime.now().month, @@ -30,7 +31,16 @@ void main() async { testWidgets('When given a single room', (tester) async { final rooms = ['B315']; - final exam = Exam('1230', start, finish, subject, rooms, '', 'feup'); + final exam = Exam( + '1230', + start, + finish, + subjectAcronym, + subject, + rooms, + '', + 'feup', + ); final widget = ExamRow( exam: exam, teacher: '', @@ -44,7 +54,7 @@ void main() async { await tester.pumpWidget(testableWidget(widget, providers: providers)); await tester.pump(); - final roomsKey = '$subject-$rooms-$startTime-$finishTime'; + final roomsKey = '$subjectAcronym-$rooms-$startTime-$finishTime'; expect( find.descendant( @@ -57,7 +67,16 @@ void main() async { testWidgets('When multiple rooms', (tester) async { final rooms = ['B315', 'B316', 'B330']; - final exam = Exam('1230', start, finish, subject, rooms, '', 'feup'); + final exam = Exam( + '1230', + start, + finish, + subjectAcronym, + subject, + rooms, + '', + 'feup', + ); final widget = ExamRow( exam: exam, teacher: '', @@ -72,7 +91,7 @@ void main() async { await tester.pumpWidget(testableWidget(widget, providers: providers)); await tester.pump(); - final roomsKey = '$subject-$rooms-$startTime-$finishTime'; + final roomsKey = '$subjectAcronym-$rooms-$startTime-$finishTime'; expect( find.descendant(