[Vulcan/Hebe] Fix getting attendance.

This commit is contained in:
Kuba Szczodrzyński 2021-02-21 23:03:06 +01:00
parent 6c0ddd3e6d
commit 5903bbe59d

View File

@ -8,9 +8,11 @@ import com.google.gson.JsonObject
import pl.szczodrzynski.edziennik.* import pl.szczodrzynski.edziennik.*
import pl.szczodrzynski.edziennik.data.api.VULCAN_HEBE_ENDPOINT_ATTENDANCE import pl.szczodrzynski.edziennik.data.api.VULCAN_HEBE_ENDPOINT_ATTENDANCE
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.DataVulcan
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.ENDPOINT_VULCAN_HEBE_ATTENDANCE
import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.VulcanHebe import pl.szczodrzynski.edziennik.data.api.edziennik.vulcan.data.VulcanHebe
import pl.szczodrzynski.edziennik.data.db.entity.Attendance import pl.szczodrzynski.edziennik.data.db.entity.Attendance
import pl.szczodrzynski.edziennik.data.db.entity.Metadata import pl.szczodrzynski.edziennik.data.db.entity.Metadata
import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS
class VulcanHebeAttendance( class VulcanHebeAttendance(
override val data: DataVulcan, override val data: DataVulcan,
@ -23,10 +25,16 @@ class VulcanHebeAttendance(
} }
init { init {
val semesterNumber = data.studentSemesterNumber
val startDate = profile?.getSemesterStart(semesterNumber)
val endDate = profile?.getSemesterEnd(semesterNumber)
apiGetList( apiGetList(
TAG, TAG,
VULCAN_HEBE_ENDPOINT_ATTENDANCE, VULCAN_HEBE_ENDPOINT_ATTENDANCE,
HebeFilterType.BY_PUPIL, HebeFilterType.BY_PUPIL,
dateFrom = startDate,
dateTo = endDate,
lastSync = lastSync lastSync = lastSync
) { list, _ -> ) { list, _ ->
list.forEach { attendance -> list.forEach { attendance ->
@ -88,12 +96,19 @@ class VulcanHebeAttendance(
profileId, profileId,
Metadata.TYPE_ATTENDANCE, Metadata.TYPE_ATTENDANCE,
attendanceObject.id, attendanceObject.id,
profile?.empty ?: true || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == Attendance.TYPE_UNKNOWN, profile?.empty ?: true
profile?.empty ?: true || baseType == Attendance.TYPE_PRESENT_CUSTOM || baseType == Attendance.TYPE_UNKNOWN || baseType == Attendance.TYPE_PRESENT_CUSTOM
|| baseType == Attendance.TYPE_UNKNOWN,
profile?.empty ?: true
|| baseType == Attendance.TYPE_PRESENT_CUSTOM
|| baseType == Attendance.TYPE_UNKNOWN
) )
) )
} }
} }
data.setSyncNext(ENDPOINT_VULCAN_HEBE_ATTENDANCE, SYNC_ALWAYS)
onSuccess(ENDPOINT_VULCAN_HEBE_ATTENDANCE)
} }
} }