Add support for detect whole day excuses in old student module

This commit is contained in:
Mikołaj Pich 2024-02-29 23:56:48 +01:00
parent b7081d1ac1
commit e077867957
2 changed files with 4 additions and 3 deletions

View file

@ -442,7 +442,7 @@ class Scrapper {
suspend fun getRegisteredDevices(): List<Device> = student.getRegisteredDevices()
suspend fun getToken(): TokenResponse {
return when(isEduOne) {
return when (isEduOne) {
true -> studentPlus.getToken()
else -> student.getToken()
}

View file

@ -3,7 +3,6 @@ package io.github.wulkanowy.sdk.scrapper.attendance
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.ABSENCE_UNEXCUSED
import io.github.wulkanowy.sdk.scrapper.attendance.AttendanceCategory.UNEXCUSED_LATENESS
import io.github.wulkanowy.sdk.scrapper.timetable.CacheResponse.Time
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.time.LocalDate
@ -12,7 +11,9 @@ import java.time.Month
internal fun AttendanceResponse.mapAttendanceList(start: LocalDate, end: LocalDate?, times: List<Time>): List<Attendance> {
val endDate = end ?: start.plusDays(4)
return lessons.map {
val sentExcuse = sentExcuses.firstOrNull { excuse -> excuse.date == it.date && excuse.timeId == it.timeId }
val sentExcuse = sentExcuses.firstOrNull { excuse ->
excuse.date == it.date && (excuse.timeId == it.timeId || excuse.timeId == null)
}
it.copy(
number = times.single { time -> time.id == it.timeId }.number,
).apply {