Add grades summary and averages

This commit is contained in:
Mikołaj Pich 2023-04-18 23:07:00 +02:00
parent 24b5b16f72
commit a18fe84ce7
9 changed files with 366 additions and 16 deletions

View file

@ -5,6 +5,8 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
public final fun getBaseUrl ()Ljava/lang/String;
public final fun getDeviceModel ()Ljava/lang/String;
public final fun getGrades (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGradesAverage (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGradesSummary (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getKeyId ()Ljava/lang/String;
public final fun getLogLevel ()Lokhttp3/logging/HttpLoggingInterceptor$Level;
public final fun getPrivatePem ()Ljava/lang/String;
@ -350,6 +352,194 @@ public final class io/github/wulkanowy/sdk/hebe/models/Grade$Modifier$Companion
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Companion;
public synthetic fun <init> (ILjava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()I
public final fun component3 ()I
public final fun component4 ()I
public final fun component5 ()Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;
public final fun copy (Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;
public fun equals (Ljava/lang/Object;)Z
public final fun getAverage ()Ljava/lang/String;
public final fun getId ()I
public final fun getPeriodId ()I
public final fun getPupilId ()I
public final fun getSubject ()Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/GradeAverage;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject$Companion;
public synthetic fun <init> (IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
public final fun component1 ()I
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()I
public final fun copy (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;
public fun equals (Ljava/lang/Object;)Z
public final fun getId ()I
public final fun getKey ()Ljava/lang/String;
public final fun getKod ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getPosition ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeAverage$Subject$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Companion;
public synthetic fun <init> (ILio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;)V
public synthetic fun <init> (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()I
public final fun component5 ()I
public final fun component6 ()I
public final fun component7 ()Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;
public final fun copy (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;IIILio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;
public fun equals (Ljava/lang/Object;)Z
public final fun getDateModify ()Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;
public final fun getEntry1 ()Ljava/lang/String;
public final fun getEntry2 ()Ljava/lang/String;
public final fun getId ()I
public final fun getPeriodId ()I
public final fun getPupilId ()I
public final fun getSubject ()Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/GradeSummary;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify$Companion;
public synthetic fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()J
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;
public fun equals (Ljava/lang/Object;)Z
public final fun getDate ()Ljava/lang/String;
public final fun getDateDisplay ()Ljava/lang/String;
public final fun getTime ()Ljava/lang/String;
public final fun getTimestamp ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$DateModify$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject {
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject$Companion;
public synthetic fun <init> (IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
public final fun component1 ()I
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()I
public final fun copy (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;
public fun equals (Ljava/lang/Object;)Z
public final fun getId ()I
public final fun getKey ()Ljava/lang/String;
public final fun getKod ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getPosition ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lio/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/models/GradeSummary$Subject$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class io/github/wulkanowy/sdk/hebe/register/RegisterDevice {
public fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public final fun component1 ()I

View file

@ -1,6 +1,8 @@
package io.github.wulkanowy.sdk.hebe
import io.github.wulkanowy.sdk.hebe.models.Grade
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
import io.github.wulkanowy.sdk.hebe.register.RegisterDevice
import io.github.wulkanowy.sdk.hebe.register.StudentInfo
import io.github.wulkanowy.sdk.hebe.repository.RepositoryManager
@ -120,6 +122,20 @@ class Hebe {
return studentRepository.getGrades(
pupilId = pupilId,
periodId = periodId,
).orEmpty()
)
}
suspend fun getGradesSummary(periodId: Int): List<GradeSummary> {
return studentRepository.getGradesSummary(
pupilId = pupilId,
periodId = periodId,
)
}
suspend fun getGradesAverage(periodId: Int): List<GradeAverage> {
return studentRepository.getGradesAverage(
pupilId = pupilId,
periodId = periodId,
)
}
}

View file

@ -0,0 +1,34 @@
package io.github.wulkanowy.sdk.hebe.models
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class GradeAverage(
@SerialName("Average")
val average: String,
@SerialName("Id")
val id: Int,
@SerialName("PeriodId")
val periodId: Int,
// @SerialName("Points")
// val points: Any?,
@SerialName("PupilId")
val pupilId: Int,
@SerialName("Subject")
val subject: Subject,
) {
@Serializable
data class Subject(
@SerialName("Id")
val id: Int,
@SerialName("Key")
val key: String,
@SerialName("Kod")
val kod: String,
@SerialName("Name")
val name: String,
@SerialName("Position")
val position: Int,
)
}

View file

@ -0,0 +1,50 @@
package io.github.wulkanowy.sdk.hebe.models
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class GradeSummary(
@SerialName("DateModify")
val dateModify: DateModify,
@SerialName("Entry_1")
val entry1: String? = null,
@SerialName("Entry_2")
val entry2: String? = null,
// @SerialName("Entry_3")
// val entry3: Any?,
@SerialName("Id")
val id: Int,
@SerialName("PeriodId")
val periodId: Int,
@SerialName("PupilId")
val pupilId: Int,
@SerialName("Subject")
val subject: Subject,
) {
@Serializable
data class DateModify(
@SerialName("Date")
val date: String,
@SerialName("DateDisplay")
val dateDisplay: String,
@SerialName("Time")
val time: String,
@SerialName("Timestamp")
val timestamp: Long,
)
@Serializable
data class Subject(
@SerialName("Id")
val id: Int,
@SerialName("Key")
val key: String,
@SerialName("Kod")
val kod: String,
@SerialName("Name")
val name: String,
@SerialName("Position")
val position: Int,
)
}

View file

@ -2,6 +2,8 @@ package io.github.wulkanowy.sdk.hebe.repository
import io.github.wulkanowy.sdk.hebe.getEnvelopeOrThrowError
import io.github.wulkanowy.sdk.hebe.models.Grade
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
import io.github.wulkanowy.sdk.hebe.service.StudentService
internal class StudentRepository(private val studentService: StudentService) {
@ -12,4 +14,18 @@ internal class StudentRepository(private val studentService: StudentService) {
periodId = periodId,
).getEnvelopeOrThrowError().orEmpty()
}
suspend fun getGradesSummary(pupilId: Int, periodId: Int): List<GradeSummary> {
return studentService.getGradesSummary(
pupilId = pupilId,
periodId = periodId,
).getEnvelopeOrThrowError().orEmpty()
}
suspend fun getGradesAverage(pupilId: Int, periodId: Int): List<GradeAverage> {
return studentService.getGradesAverage(
pupilId = pupilId,
periodId = periodId,
).getEnvelopeOrThrowError().orEmpty()
}
}

View file

@ -2,6 +2,8 @@ package io.github.wulkanowy.sdk.hebe.service
import io.github.wulkanowy.sdk.hebe.ApiResponse
import io.github.wulkanowy.sdk.hebe.models.Grade
import io.github.wulkanowy.sdk.hebe.models.GradeAverage
import io.github.wulkanowy.sdk.hebe.models.GradeSummary
import retrofit2.http.GET
import retrofit2.http.Query
@ -15,4 +17,22 @@ internal interface StudentService {
@Query("lastId") lastId: Int = Int.MIN_VALUE,
@Query("pageSize") pageSize: Int = 500,
): ApiResponse<List<Grade>>
@GET("api/mobile/grade/average/byPupil")
suspend fun getGradesSummary(
@Query("pupilId") pupilId: Int,
@Query("periodId") periodId: Int,
@Query("lastSyncDate") lastSyncDate: String = "1970-01-01 01:00:00",
@Query("lastId") lastId: Int = Int.MIN_VALUE,
@Query("pageSize") pageSize: Int = 500,
): ApiResponse<List<GradeSummary>>
@GET("api/mobile/grade/average/byPupil")
suspend fun getGradesAverage(
@Query("pupilId") pupilId: Int,
@Query("periodId") periodId: Int,
@Query("lastSyncDate") lastSyncDate: String = "1970-01-01 01:00:00",
@Query("lastId") lastId: Int = Int.MIN_VALUE,
@Query("pageSize") pageSize: Int = 500,
): ApiResponse<List<GradeAverage>>
}

View file

@ -43,4 +43,10 @@ class HebeRemoteTest {
val grades = hebe.getGrades(559)
assertTrue(grades.isNotEmpty())
}
@Test
fun `get grades summary`() = runTest {
val summaries = hebe.getGradesSummary(559)
assertTrue(summaries.isNotEmpty())
}
}

View file

@ -371,7 +371,11 @@ class Sdk {
suspend fun getGrades(semesterId: Int): Grades = withContext(Dispatchers.IO) {
when (mode) {
Mode.SCRAPPER -> scrapper.getGrades(semesterId).mapGrades()
Mode.HYBRID, Mode.HEBE -> hebe.getGrades(semesterId).mapGrades()
Mode.HYBRID, Mode.HEBE -> Triple(
hebe.getGrades(semesterId),
hebe.getGradesSummary(semesterId),
hebe.getGradesAverage(semesterId),
).mapGrades()
}
}

View file

@ -6,6 +6,8 @@ import io.github.wulkanowy.sdk.pojo.Grades
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import io.github.wulkanowy.sdk.hebe.models.Grade as HebeGrade
import io.github.wulkanowy.sdk.hebe.models.GradeSummary as HebeGradeSummary
import io.github.wulkanowy.sdk.hebe.models.GradeAverage as HebeGradeAverage
import io.github.wulkanowy.sdk.scrapper.grades.Grade as ScrapperGrade
import io.github.wulkanowy.sdk.scrapper.grades.GradeSummary as ScrapperGradeSummary
import io.github.wulkanowy.sdk.scrapper.grades.Grades as ScrapperGrades
@ -48,24 +50,36 @@ internal fun ScrapperGrades.mapGrades() = Grades(
type = type,
)
internal fun List<HebeGrade>.mapGrades() = Grades(
details = map {
internal fun Triple<List<HebeGrade>, List<HebeGradeSummary>, List<HebeGradeAverage>>.mapGrades() = Grades(
details = first.map { grade ->
Grade(
subject = it.column.subject.name,
entry = it.content,
value = it.value ?: 0.0,
subject = grade.column.subject.name,
entry = grade.content,
value = grade.value ?: 0.0,
modifier = 0.0,
weight = it.column.weight.toString(),
weightValue = it.column.weight,
comment = it.comment,
symbol = it.column.code,
description = it.column.name,
color = it.column.color.toString(16).uppercase(),
teacher = "${it.creator.name} ${it.creator.surname}",
date = LocalDate.parse(it.dateCreated.date, DateTimeFormatter.ofPattern("yyyy-MM-dd")),
weight = String.format("%.2f", grade.column.weight),
weightValue = grade.column.weight,
comment = grade.comment,
symbol = grade.column.code,
description = grade.column.name,
color = grade.column.color.toString(16).uppercase(),
teacher = "${grade.creator.name} ${grade.creator.surname}",
date = LocalDate.parse(grade.dateCreated.date, DateTimeFormatter.ofPattern("yyyy-MM-dd")),
)
},
summary = second.map { summary ->
GradeSummary(
name = summary.subject.name,
average = third.find { it.id == summary.id }
?.average?.replace(",", ".")
?.toDoubleOrNull() ?: .0,
predicted = summary.entry1.orEmpty(),
final = summary.entry2.orEmpty(),
pointsSum = "",
proposedPoints = "",
finalPoints = "",
)
},
summary = listOf(),
isAverage = false,
isPoints = false,
isForAdults = false,