From 66cfe3e99696a61947893def361435f976cd58f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Mon, 13 Sep 2021 12:37:23 +0200 Subject: [PATCH] Split teacher in exams mapper only once --- .../io/github/wulkanowy/sdk/scrapper/exams/ExamsMapper.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/exams/ExamsMapper.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/exams/ExamsMapper.kt index 12247d38..94d47b1b 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/exams/ExamsMapper.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/exams/ExamsMapper.kt @@ -8,8 +8,9 @@ fun List.mapExamsList(startDate: LocalDate, endDate: LocalDate?): return asSequence().map { weeks -> weeks.weeks.map { day -> day.exams.map { exam -> + val teacherAndSymbol = exam.teacher.split(" [") exam.copy( - teacher = exam.teacher.split(" [").first(), + teacher = teacherAndSymbol.first(), subject = exam.subject, type = when (exam.type) { "1" -> "Sprawdzian" @@ -19,7 +20,7 @@ fun List.mapExamsList(startDate: LocalDate, endDate: LocalDate?): ).apply { date = day.date - teacherSymbol = exam.teacher.split(" [").last().removeSuffix("]") + teacherSymbol = teacherAndSymbol.last().removeSuffix("]") } } }.flatten()