diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 051ac1bda..cbd989070 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -14,12 +14,19 @@ jobs: with: token: ${{ secrets.NIAEFEUPBOT_PAT }} + - name: Get develop hash + if: github.ref == 'refs/heads/master' + run: | + git fetch origin develop + current_hash=$(git rev-parse origin/develop) + echo "DEVELOPHASH=$current_hash" >> $GITHUB_ENV + - name: Bump flutter patch version - if: github.ref == 'refs/heads/develop' + if: github.ref == 'refs/heads/develop' || github.sha != env.DEVELOPHASH run: perl -i -pe 's/^(\d+\.\d+\.)(\d+)(\+)(\d+)$/$1.($2+1).($3).($4+1)/e' ${{ env.APP_VERSION_PATH }} - name: Bump flutter minor version - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' && github.sha == env.DEVELOPHASH run: perl -i -pe 's/^(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.($2).($3+1).($4).(0).($6).($7+1)/e' ${{ env.APP_VERSION_PATH }} - name: Copy app version to pubspec @@ -28,7 +35,6 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: "Bump app version [no ci]" - - name: Propagate master version bump to develop if: github.ref == 'refs/heads/master' run: git push --force-with-lease origin HEAD:develop diff --git a/uni/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_html.dart b/uni/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_html.dart index 6d9594a4b..7fdf7ed16 100644 --- a/uni/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_html.dart +++ b/uni/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_html.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:http/http.dart'; import 'package:uni/controller/fetchers/schedule_fetcher/schedule_fetcher.dart'; import 'package:uni/controller/networking/network_router.dart'; @@ -39,8 +40,11 @@ class ScheduleFetcherHtml extends ScheduleFetcher { } final lectures = await Future.wait( - lectureResponses - .map((response) => getScheduleFromHtml(response, session)), + IterableZip( + [lectureResponses, NetworkRouter.getBaseUrlsFromSession(session)], + ).map( + (e) => getScheduleFromHtml(e[0] as Response, session, e[1] as String), + ), ).then((schedules) => schedules.expand((schedule) => schedule).toList()); lectures.sort((l1, l2) => l1.compare(l2)); diff --git a/uni/lib/controller/parsers/parser_schedule_html.dart b/uni/lib/controller/parsers/parser_schedule_html.dart index 88ac5ce8c..6843f749d 100644 --- a/uni/lib/controller/parsers/parser_schedule_html.dart +++ b/uni/lib/controller/parsers/parser_schedule_html.dart @@ -11,6 +11,7 @@ import 'package:uni/model/entities/time_utilities.dart'; Future> getOverlappedClasses( Session session, Document document, + String faculty, ) async { final lecturesList = []; @@ -21,7 +22,7 @@ Future> getOverlappedClasses( final subject = element.querySelector('acronym > a')?.text; final typeClass = element .querySelector('td[headers=t1]') - ?.nodes[2] + ?.nodes[1] .text ?.trim() .replaceAll(RegExp('[()]+'), ''); @@ -37,22 +38,33 @@ Future> getOverlappedClasses( final classNumber = element.querySelector('td[headers=t6] > a')?.text; try { + final startTimeList = startTime?.split(':') ?? []; + if (startTimeList.isEmpty) { + throw FormatException( + 'Overlapping class $subject has invalid startTime', + ); + } final fullStartTime = monday.add( Duration( days: day, - hours: int.parse(startTime!.substring(0, 2)), - minutes: int.parse(startTime.substring(3, 5)), + hours: int.parse(startTimeList[0]), + minutes: int.parse(startTimeList[1]), ), ); - final link = + final href = element.querySelector('td[headers=t6] > a')?.attributes['href']; - if (link == null) { + if (href == null) { throw Exception(); } - final response = await NetworkRouter.getWithCookies(link, {}, session); + final response = await NetworkRouter.getWithCookies( + '$faculty$href', + {}, + session, + ); - final classLectures = await getScheduleFromHtml(response, session); + final classLectures = + await getScheduleFromHtml(response, session, faculty); lecturesList.add( classLectures @@ -88,6 +100,7 @@ Future> getOverlappedClasses( Future> getScheduleFromHtml( http.Response response, Session session, + String faculty, ) async { final document = parse(response.body); var semana = [0, 0, 0, 0, 0, 0]; @@ -148,7 +161,9 @@ Future> getScheduleFromHtml( }); lecturesList - ..addAll(await getOverlappedClasses(session, document)) + ..addAll( + await getOverlappedClasses(session, document, faculty), + ) ..sort((a, b) => a.compare(b)); return lecturesList; diff --git a/uni/lib/model/entities/lecture.dart b/uni/lib/model/entities/lecture.dart index f91658b2e..b93aac32c 100644 --- a/uni/lib/model/entities/lecture.dart +++ b/uni/lib/model/entities/lecture.dart @@ -51,10 +51,11 @@ class Lecture { String classNumber, int occurrId, ) { + final startTimeList = startTimeString.split(':'); final startTime = day.add( Duration( - hours: int.parse(startTimeString.substring(0, 2)), - minutes: int.parse(startTimeString.substring(3, 5)), + hours: int.parse(startTimeList[0]), + minutes: int.parse(startTimeList[1]), ), ); final endTime = startTime.add(Duration(minutes: 30 * blocks));