From b7f7b16aef883a4572efd9366205b18cfbc50c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Tue, 26 Mar 2024 12:54:07 +0100 Subject: [PATCH 1/2] Add logging error from units and symbols during registration (#2507) --- app/build.gradle | 2 +- .../data/repositories/StudentRepository.kt | 23 +++++++++++++++---- .../wulkanowy/utils/SemesterExtension.kt | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d7174a2d..d69ea5a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -195,7 +195,7 @@ ext { } dependencies { - implementation 'io.github.wulkanowy:sdk:2.5.3' + implementation 'io.github.wulkanowy:sdk:2.5.4-SNAPSHOT' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/StudentRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/StudentRepository.kt index 61d6255b..df47d7a6 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/StudentRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/StudentRepository.kt @@ -42,6 +42,7 @@ class StudentRepository @Inject constructor( ): RegisterUser = wulkanowySdkFactory.create() .getStudentsFromHebe(token, pin, symbol, "") .mapToPojo(null) + .also { it.logErrors() } suspend fun getUserSubjectsFromScrapper( email: String, @@ -52,6 +53,7 @@ class StudentRepository @Inject constructor( ): RegisterUser = wulkanowySdkFactory.create() .getUserSubjectsFromScrapper(email, password, scrapperBaseUrl, domainSuffix, symbol) .mapToPojo(password) + .also { it.logErrors() } suspend fun getStudentsHybrid( email: String, @@ -61,6 +63,7 @@ class StudentRepository @Inject constructor( ): RegisterUser = wulkanowySdkFactory.create() .getStudentsHybrid(email, password, scrapperBaseUrl, "", symbol) .mapToPojo(password) + .also { it.logErrors() } suspend fun getSavedStudents(decryptPass: Boolean = true): List { return studentDb.loadStudentsWithSemesters().map { (student, semesters) -> @@ -195,10 +198,10 @@ class StudentRepository @Inject constructor( .authorizePermission(pesel) suspend fun refreshStudentAfterAuthorize(student: Student, semester: Semester) { - val newCurrentApiStudent = wulkanowySdkFactory - .create(student, semester) - .getCurrentStudent() - ?: return Timber.d("Can't find student with id ${student.studentId}") + val wulkanowySdk = wulkanowySdkFactory.create(student, semester) + val newCurrentApiStudent = runCatching { wulkanowySdk.getCurrentStudent() } + .onFailure { Timber.e(it, "Can't find student with id ${student.studentId}") } + .getOrNull() ?: return val studentName = StudentName( studentName = "${newCurrentApiStudent.studentName} ${newCurrentApiStudent.studentSurname}" @@ -221,6 +224,18 @@ class StudentRepository @Inject constructor( appDatabase.clearAllTables() } } + + private fun RegisterUser.logErrors() { + val symbolsErrors = symbols.filter { it.error != null } + .map { it.error } + val unitsErrors = symbols.flatMap { it.schools } + .filter { it.error != null } + .map { it.error } + + (symbolsErrors + unitsErrors).forEach { error -> + Timber.e(error, "Error occurred while fetching students") + } + } } class NoAuthorizationException : Exception() diff --git a/app/src/main/java/io/github/wulkanowy/utils/SemesterExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/SemesterExtension.kt index e3b8a3b4..6cfc4fa1 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/SemesterExtension.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/SemesterExtension.kt @@ -18,7 +18,7 @@ fun Semester.isCurrent(now: LocalDate = now()): Boolean { } fun List.getCurrentOrLast(): Semester { - if (isEmpty()) throw RuntimeException("Empty semester list") + if (isEmpty()) throw IllegalStateException("Empty semester list") // when there is only one current semester singleOrNull { it.isCurrent() }?.let { return it } From 8cdd4311a903f592c6bd110f0cd933b2de2f8f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 26 Mar 2024 13:29:22 +0100 Subject: [PATCH 2/2] Version 2.5.4 --- app/build.gradle | 10 +++++----- app/src/main/play/release-notes/pl-PL/default.txt | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d69ea5a3..92633dd3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,8 +27,8 @@ android { testApplicationId "io.github.tests.wulkanowy" minSdkVersion 21 targetSdkVersion 34 - versionCode 152 - versionName "2.5.3" + versionCode 153 + versionName "2.5.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "app_name", "Wulkanowy" @@ -164,8 +164,8 @@ play { defaultToAppBundles = false track = 'production' releaseStatus = ReleaseStatus.IN_PROGRESS - userFraction = 0.20d - updatePriority = 3 + userFraction = 0.99d + updatePriority = 1 enabled.set(false) } @@ -195,7 +195,7 @@ ext { } dependencies { - implementation 'io.github.wulkanowy:sdk:2.5.4-SNAPSHOT' + implementation 'io.github.wulkanowy:sdk:2.5.4' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' diff --git a/app/src/main/play/release-notes/pl-PL/default.txt b/app/src/main/play/release-notes/pl-PL/default.txt index cd41a98b..d848d01c 100644 --- a/app/src/main/play/release-notes/pl-PL/default.txt +++ b/app/src/main/play/release-notes/pl-PL/default.txt @@ -1,8 +1,5 @@ -Wersja 2.5.3 +Wersja 2.5.4 -— naprawiliśmy wyświetlanie błędu "Brak uprawnień" po starcie aplikacji u użytkowników eduOne -— naprawiliśmy obsługę autoryzacji u użytkowników eduOne -— ukryliśmy numery lekcji i oceny klasy u użytkowników eduOne, bo VULCAN te funkcje usunął -— naprawiliśmy inne rzeczy u użytkowników eduOne (jak brak opisu oceny czy ładowanie danych na kilku ekranach) +— naprawiliśmy kolejnych kilka błędów związanych z obsługą dziennika eduOne (tak, nie umiemy za jednym razem) Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases