mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 02:56:45 -06:00
Merge branch 'hotfix/all-year-average' into develop
This commit is contained in:
commit
6855296de4
@ -22,8 +22,8 @@ android {
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 90
|
||||
versionName "1.1.4"
|
||||
versionCode 91
|
||||
versionName "1.1.5"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
@ -137,7 +137,7 @@ play {
|
||||
serviceAccountCredentials = file('key.p12')
|
||||
defaultToAppBundles = false
|
||||
track = 'production'
|
||||
updatePriority = 3
|
||||
updatePriority = 1
|
||||
}
|
||||
|
||||
huaweiPublish {
|
||||
@ -161,7 +161,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:877b9135"
|
||||
implementation "io.github.wulkanowy:sdk:07a21c1"
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||
|
||||
|
@ -70,7 +70,7 @@ class GradeAverageProvider @Inject constructor(
|
||||
forceRefresh: Boolean,
|
||||
averageMode: GradeAverageMode
|
||||
): Flow<Resource<List<GradeSubject>>> {
|
||||
val gradeAverageForceCalc = preferencesRepository.gradeAverageForceCalc
|
||||
val isGradeAverageForceCalc = preferencesRepository.gradeAverageForceCalc
|
||||
val selectedSemester = semesters.single { it.semesterId == semesterId }
|
||||
val firstSemester =
|
||||
semesters.single { it.diaryId == selectedSemester.diaryId && it.semesterName == 1 }
|
||||
@ -80,8 +80,7 @@ class GradeAverageProvider @Inject constructor(
|
||||
|
||||
if (selectedSemester == firstSemester) return selectedSemesterGradeSubjects
|
||||
|
||||
val firstSemesterGradeSubjects =
|
||||
getGradeSubjects(student, firstSemester, forceRefresh)
|
||||
val firstSemesterGradeSubjects = getGradeSubjects(student, firstSemester, forceRefresh)
|
||||
|
||||
return selectedSemesterGradeSubjects.combine(firstSemesterGradeSubjects) { secondSemesterGradeSubject, firstSemesterGradeSubject ->
|
||||
if (firstSemesterGradeSubject.status == Status.ERROR) {
|
||||
@ -89,9 +88,9 @@ class GradeAverageProvider @Inject constructor(
|
||||
}
|
||||
|
||||
val isAnyVulcanAverageInFirstSemester =
|
||||
firstSemesterGradeSubject.data.orEmpty().any { it.average != .0 }
|
||||
firstSemesterGradeSubject.data.orEmpty().any { it.isVulcanAverage }
|
||||
val isAnyVulcanAverageInSecondSemester =
|
||||
secondSemesterGradeSubject.data.orEmpty().any { it.average != .0 }
|
||||
secondSemesterGradeSubject.data.orEmpty().any { it.isVulcanAverage }
|
||||
|
||||
val updatedData = secondSemesterGradeSubject.data?.map { secondSemesterSubject ->
|
||||
val firstSemesterSubject = firstSemesterGradeSubject.data.orEmpty()
|
||||
@ -101,7 +100,7 @@ class GradeAverageProvider @Inject constructor(
|
||||
calculateAllYearAverage(
|
||||
student = student,
|
||||
isAnyVulcanAverage = isAnyVulcanAverageInFirstSemester || isAnyVulcanAverageInSecondSemester,
|
||||
gradeAverageForceCalc = gradeAverageForceCalc,
|
||||
isGradeAverageForceCalc = isGradeAverageForceCalc,
|
||||
secondSemesterSubject = secondSemesterSubject,
|
||||
firstSemesterSubject = firstSemesterSubject
|
||||
)
|
||||
@ -109,7 +108,7 @@ class GradeAverageProvider @Inject constructor(
|
||||
calculateBothSemestersAverage(
|
||||
student = student,
|
||||
isAnyVulcanAverage = isAnyVulcanAverageInFirstSemester || isAnyVulcanAverageInSecondSemester,
|
||||
gradeAverageForceCalc = gradeAverageForceCalc,
|
||||
isGradeAverageForceCalc = isGradeAverageForceCalc,
|
||||
secondSemesterSubject = secondSemesterSubject,
|
||||
firstSemesterSubject = firstSemesterSubject
|
||||
)
|
||||
@ -123,10 +122,10 @@ class GradeAverageProvider @Inject constructor(
|
||||
private fun calculateAllYearAverage(
|
||||
student: Student,
|
||||
isAnyVulcanAverage: Boolean,
|
||||
gradeAverageForceCalc: Boolean,
|
||||
isGradeAverageForceCalc: Boolean,
|
||||
secondSemesterSubject: GradeSubject,
|
||||
firstSemesterSubject: GradeSubject?
|
||||
) = if (!isAnyVulcanAverage || gradeAverageForceCalc) {
|
||||
) = if (!isAnyVulcanAverage || isGradeAverageForceCalc) {
|
||||
val updatedSecondSemesterGrades =
|
||||
secondSemesterSubject.grades.updateModifiers(student)
|
||||
val updatedFirstSemesterGrades =
|
||||
@ -140,13 +139,13 @@ class GradeAverageProvider @Inject constructor(
|
||||
private fun calculateBothSemestersAverage(
|
||||
student: Student,
|
||||
isAnyVulcanAverage: Boolean,
|
||||
gradeAverageForceCalc: Boolean,
|
||||
isGradeAverageForceCalc: Boolean,
|
||||
secondSemesterSubject: GradeSubject,
|
||||
firstSemesterSubject: GradeSubject?
|
||||
): Double {
|
||||
val divider = if (secondSemesterSubject.grades.any { it.weightValue > .0 }) 2 else 1
|
||||
|
||||
return if (!isAnyVulcanAverage || gradeAverageForceCalc) {
|
||||
return if (!isAnyVulcanAverage || isGradeAverageForceCalc) {
|
||||
val secondSemesterAverage =
|
||||
secondSemesterSubject.grades.updateModifiers(student).calcAverage(isOptionalArithmeticAverage)
|
||||
val firstSemesterAverage = firstSemesterSubject?.grades?.updateModifiers(student)
|
||||
@ -163,7 +162,7 @@ class GradeAverageProvider @Inject constructor(
|
||||
semester: Semester,
|
||||
forceRefresh: Boolean
|
||||
): Flow<Resource<List<GradeSubject>>> {
|
||||
val gradeAverageForceCalc = preferencesRepository.gradeAverageForceCalc
|
||||
val isGradeAverageForceCalc = preferencesRepository.gradeAverageForceCalc
|
||||
|
||||
return gradeRepository.getGrades(student, semester, forceRefresh = forceRefresh)
|
||||
.map { res ->
|
||||
@ -172,20 +171,21 @@ class GradeAverageProvider @Inject constructor(
|
||||
val allGrades = details.orEmpty().groupBy { it.subject }
|
||||
|
||||
val items = summaries?.emulateEmptySummaries(
|
||||
student,
|
||||
semester,
|
||||
allGrades.toList(),
|
||||
isAnyAverage
|
||||
student = student,
|
||||
semester = semester,
|
||||
grades = allGrades.toList(),
|
||||
calcAverage = isAnyAverage
|
||||
)?.map { summary ->
|
||||
val grades = allGrades[summary.subject].orEmpty()
|
||||
GradeSubject(
|
||||
subject = summary.subject,
|
||||
average = if (!isAnyAverage || gradeAverageForceCalc) {
|
||||
average = if (!isAnyAverage || isGradeAverageForceCalc) {
|
||||
grades.updateModifiers(student).calcAverage(isOptionalArithmeticAverage)
|
||||
} else summary.average,
|
||||
points = summary.pointsSum,
|
||||
summary = summary,
|
||||
grades = grades
|
||||
grades = grades,
|
||||
isVulcanAverage = isAnyAverage
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -8,5 +8,6 @@ data class GradeSubject(
|
||||
val average: Double,
|
||||
val points: String,
|
||||
val summary: GradeSummary,
|
||||
val grades: List<Grade>
|
||||
val grades: List<Grade>,
|
||||
val isVulcanAverage: Boolean
|
||||
)
|
||||
|
@ -1,11 +1,5 @@
|
||||
Wersja 1.1.4
|
||||
Wersja 1.1.5
|
||||
|
||||
Oprócz tego naprawiliśmy:
|
||||
- rzadkie problemy ze stabilnością przy logowaniu i w innych miejscach
|
||||
- brakujące awatary przy zmianie konta z poziomu widżetu
|
||||
- wysyłanie wiadomości gdy w aplikacji jest zalogowany jednocześnie uczeń i rodzic
|
||||
|
||||
Ta wersja jest ostatnią, która będzie działać na starszych urządzeniach z Androidem 4.
|
||||
Od tej pory do końca roku bedziemy dla nich udostępniać wyłącznie krytyczne poprawki błędów
|
||||
Naprawiliśmy liczenie średniej wszystkich ocen z całego roku
|
||||
|
||||
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases
|
||||
|
@ -495,15 +495,71 @@ class GradeAverageProviderTest {
|
||||
)
|
||||
}
|
||||
|
||||
val items = runBlocking { gradeAverageProvider.getGradesDetailsWithAverage(student, semesters[2].semesterId, true).getResult() }
|
||||
val items = runBlocking {
|
||||
gradeAverageProvider.getGradesDetailsWithAverage(
|
||||
student,
|
||||
semesters[2].semesterId,
|
||||
true
|
||||
).getResult()
|
||||
}
|
||||
|
||||
assertEquals(2, items.size)
|
||||
assertEquals(3.0, items.single { it.subject == "Matematyka" }.average, .0) // (from details): 3,5 + 2,5 → 3,0
|
||||
assertEquals(3.25, items.single { it.subject == "Fizyka" }.average, .0) // (from details): 3,5 + 3,0 → 3,25
|
||||
assertEquals(
|
||||
3.0,
|
||||
items.single { it.subject == "Matematyka" }.average,
|
||||
.0
|
||||
) // (from details): 3,5 + 2,5 → 3,0
|
||||
assertEquals(
|
||||
3.25,
|
||||
items.single { it.subject == "Fizyka" }.average,
|
||||
.0
|
||||
) // (from details): 3,5 + 3,0 → 3,25
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `calc full year average when current is second with load from cache sequence`() {
|
||||
fun `calc all year average`() {
|
||||
every { preferencesRepository.gradeAverageMode } returns GradeAverageMode.ALL_YEAR
|
||||
every { preferencesRepository.gradeAverageForceCalc } returns false
|
||||
coEvery {
|
||||
gradeRepository.getGrades(
|
||||
student,
|
||||
semesters[1],
|
||||
true
|
||||
)
|
||||
} returns flowWithResource {
|
||||
firstGrades to listOf(
|
||||
getSummary(22, "Matematyka", .0),
|
||||
getSummary(22, "Fizyka", .0)
|
||||
)
|
||||
}
|
||||
coEvery {
|
||||
gradeRepository.getGrades(
|
||||
student,
|
||||
semesters[2],
|
||||
true
|
||||
)
|
||||
} returns flowWithResource {
|
||||
secondGrades to listOf(
|
||||
getSummary(22, "Matematyka", .0),
|
||||
getSummary(22, "Fizyka", .0)
|
||||
)
|
||||
}
|
||||
|
||||
val items = runBlocking {
|
||||
gradeAverageProvider.getGradesDetailsWithAverage(
|
||||
student,
|
||||
semesters[2].semesterId,
|
||||
true
|
||||
).getResult()
|
||||
}
|
||||
|
||||
assertEquals(2, items.size)
|
||||
assertEquals(3.0, items.single { it.subject == "Matematyka" }.average, .0)
|
||||
assertEquals(3.25, items.single { it.subject == "Fizyka" }.average, .0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `force calc full year average when current is second with load from cache sequence`() {
|
||||
every { preferencesRepository.gradeAverageForceCalc } returns true
|
||||
every { preferencesRepository.isOptionalArithmeticAverage } returns false
|
||||
every { preferencesRepository.gradeAverageMode } returns GradeAverageMode.ALL_YEAR
|
||||
@ -546,18 +602,40 @@ class GradeAverageProviderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `calc both semesters average when no summaries`() {
|
||||
fun `force calc both semesters average when no summaries`() {
|
||||
every { preferencesRepository.gradeAverageForceCalc } returns true
|
||||
every { preferencesRepository.isOptionalArithmeticAverage } returns false
|
||||
every { preferencesRepository.gradeAverageMode } returns GradeAverageMode.BOTH_SEMESTERS
|
||||
|
||||
coEvery { gradeRepository.getGrades(student, semesters[1], true) } returns flowWithResource { firstGrades to emptyList() }
|
||||
coEvery { gradeRepository.getGrades(student, semesters[2], true) } returns flowWithResource { secondGrades to emptyList() }
|
||||
coEvery {
|
||||
gradeRepository.getGrades(
|
||||
student,
|
||||
semesters[1],
|
||||
true
|
||||
)
|
||||
} returns flowWithResource { firstGrades to emptyList() }
|
||||
coEvery {
|
||||
gradeRepository.getGrades(
|
||||
student,
|
||||
semesters[2],
|
||||
true
|
||||
)
|
||||
} returns flowWithResource { secondGrades to emptyList() }
|
||||
|
||||
val items = runBlocking { gradeAverageProvider.getGradesDetailsWithAverage(student, semesters[2].semesterId, true).getResult() }
|
||||
val items = runBlocking {
|
||||
gradeAverageProvider.getGradesDetailsWithAverage(
|
||||
student,
|
||||
semesters[2].semesterId,
|
||||
true
|
||||
).getResult()
|
||||
}
|
||||
|
||||
assertEquals(2, items.size)
|
||||
assertEquals(3.0, items.single { it.subject == "Matematyka" }.average, .0) // (from details): 3,5 + 2,5 → 3,0
|
||||
assertEquals(
|
||||
3.0,
|
||||
items.single { it.subject == "Matematyka" }.average,
|
||||
.0
|
||||
) // (from details): 3,5 + 2,5 → 3,0
|
||||
assertEquals(3.25, items.single { it.subject == "Fizyka" }.average, .0) // (from details): 3,5 + 3,0 → 3,25
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user