io.github.wulkanowy.sdk.scrapper.exams.ExamsMapper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-scrapper Show documentation
Show all versions of sdk-scrapper Show documentation
Unified way of retrieving data from the UONET+ register through mobile api and scraping api
package io.github.wulkanowy.sdk.scrapper.exams
import java.time.LocalDate
internal fun List.mapExamsList(startDate: LocalDate, endDate: LocalDate?): List {
val end = endDate ?: startDate.plusDays(4)
return asSequence().map { weeks ->
weeks.weeks.map { day ->
day.exams.map { exam ->
val teacherAndSymbol = exam.teacher.split(" [")
exam.copy(
teacher = teacherAndSymbol.first(),
subject = exam.subject,
).apply {
date = day.date
typeName = when (exam.type) {
1 -> "Sprawdzian"
2 -> "Kartkówka"
else -> "Praca klasowa"
}
teacherSymbol = teacherAndSymbol.last().removeSuffix("]")
}
}
}.flatten()
}.flatten().filter {
it.date.toLocalDate() >= startDate && it.date.toLocalDate() <= end
}.sortedBy { it.date }.toList()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy