diff --git a/src/main/kotlin/io/github/wulkanowy/api/grades/GradePointsSummary.kt b/src/main/kotlin/io/github/wulkanowy/api/grades/GradePointsSummary.kt new file mode 100644 index 00000000..610eda0d --- /dev/null +++ b/src/main/kotlin/io/github/wulkanowy/api/grades/GradePointsSummary.kt @@ -0,0 +1,17 @@ +package io.github.wulkanowy.api.grades + +import com.google.gson.annotations.SerializedName + +data class GradePointsSummary( + + val semesterId: Int = 0, + + @SerializedName("Subject") + val subject: String, + + @SerializedName("Value1") + val others: Double, + + @SerializedName("Value2") + val student: Double +) diff --git a/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt b/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt index acc02f21..16a62c4c 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/grades/GradesMapper.kt @@ -70,13 +70,8 @@ fun List.mapGradesStatisticsPartial(semesterId }.flatten() } -fun List.mapGradesStatisticsPoints(semesterId: Int): List { +fun List.mapGradesStatisticsPoints(semesterId: Int): List { return map { - // TODO: use different class - GradeStatistics().apply { - this.semesterId = semesterId - grade = it.percentage - subject = it.subject - } + it.copy(semesterId = semesterId) } } diff --git a/src/main/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsResponse.kt b/src/main/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsResponse.kt index 27f23586..9cc7239f 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsResponse.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsResponse.kt @@ -23,15 +23,6 @@ class GradesStatisticsResponse { val items: List? ) - data class Points( - - @SerializedName("Subject") - val subject: String, - - @SerializedName("Label1") - val percentage: String - ) - data class Partial( @SerializedName("Subject") diff --git a/src/main/kotlin/io/github/wulkanowy/api/repository/StudentRepository.kt b/src/main/kotlin/io/github/wulkanowy/api/repository/StudentRepository.kt index d903970a..a8d6d53d 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/repository/StudentRepository.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/repository/StudentRepository.kt @@ -17,6 +17,7 @@ import io.github.wulkanowy.api.exams.mapExamsList import io.github.wulkanowy.api.getSchoolYear import io.github.wulkanowy.api.getScriptParam import io.github.wulkanowy.api.grades.Grade +import io.github.wulkanowy.api.grades.GradePointsSummary import io.github.wulkanowy.api.grades.GradeRequest import io.github.wulkanowy.api.grades.GradeStatistics import io.github.wulkanowy.api.grades.GradeSummary @@ -137,7 +138,7 @@ class StudentRepository(private val api: StudentService) { .map { it.mapGradesStatisticsPartial(semesterId) } } - fun getGradesPointsStatistics(semesterId: Int): Single> { + fun getGradesPointsStatistics(semesterId: Int): Single> { return api.getGradesPointsStatistics(GradesStatisticsRequest(semesterId)) .compose(ErrorHandlerTransformer()).map { it.data } .map { it.mapGradesStatisticsPoints(semesterId) } diff --git a/src/main/kotlin/io/github/wulkanowy/api/service/StudentService.kt b/src/main/kotlin/io/github/wulkanowy/api/service/StudentService.kt index 1d9660b2..3d13c35a 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/service/StudentService.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/service/StudentService.kt @@ -9,6 +9,7 @@ import io.github.wulkanowy.api.attendance.AttendanceSummaryResponse import io.github.wulkanowy.api.attendance.Subject import io.github.wulkanowy.api.exams.ExamRequest import io.github.wulkanowy.api.exams.ExamResponse +import io.github.wulkanowy.api.grades.GradePointsSummary import io.github.wulkanowy.api.grades.GradeRequest import io.github.wulkanowy.api.grades.GradesResponse import io.github.wulkanowy.api.grades.GradesStatisticsRequest @@ -56,7 +57,7 @@ interface StudentService { fun getGradesPartialStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single>> @POST("Statystyki.mvc/GetPunkty") - fun getGradesPointsStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single>> + fun getGradesPointsStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single>> @POST("Statystyki.mvc/GetOcenyRoczne") fun getGradesAnnualStatistics(@Body gradesStatisticsRequest: GradesStatisticsRequest): Single>> diff --git a/src/test/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsTest.kt b/src/test/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsTest.kt index 4709f79c..fd35027e 100644 --- a/src/test/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsTest.kt +++ b/src/test/kotlin/io/github/wulkanowy/api/grades/GradesStatisticsTest.kt @@ -75,7 +75,8 @@ class GradesStatisticsTest : BaseLocalTest() { fun getGradeStatisticsPoints() { with(points[0]) { assertEquals("Edukacja dla bezpieczeństwa", subject) - assertEquals("78,18", grade) + assertEquals(80.0, student, .0) + assertEquals(78.18, others, .0) } } } diff --git a/src/test/kotlin/io/github/wulkanowy/api/school/TeachersTest.kt b/src/test/kotlin/io/github/wulkanowy/api/school/TeachersTest.kt index 84f5a837..bb0474fc 100644 --- a/src/test/kotlin/io/github/wulkanowy/api/school/TeachersTest.kt +++ b/src/test/kotlin/io/github/wulkanowy/api/school/TeachersTest.kt @@ -20,7 +20,6 @@ class TeachersTest : BaseLocalTest() { assertEquals(3, student.size) } - @Test fun getTeacher_std() { listOf(snp[2], student[2]).map {