All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.wulkanowy.sdk.scrapper.exams.ExamsMapper.kt Maven / Gradle / Ivy

Go to download

Unified way of retrieving data from the UONET+ register through mobile api and scraping api

There is a newer version: 2.7.0
Show newest version
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