Filter empty teachers

This commit is contained in:
Mikołaj Pich 2019-11-17 00:54:18 +01:00
parent e92a8d0e20
commit 433cd83357
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA

View file

@ -6,11 +6,12 @@ import io.github.wulkanowy.sdk.scrapper.school.Teacher as ScrapperTeacher
import io.github.wulkanowy.sdk.mobile.school.Teacher as ApiTeacher
fun List<ApiTeacher>.mapTeachers(dictionaries: Dictionaries): List<Teacher> {
return map { teacher ->
return mapNotNull { teacher ->
val item = dictionaries.employees.singleOrNull { it.id == teacher.employeeId }
if (item?.name == null) return@mapNotNull null
Teacher(
name = "${item?.name} ${item?.surname}",
short = "${item?.code}",
name = "${item.name} ${item.surname}",
short = item.code,
subject = dictionaries.subjects.singleOrNull { it.id == teacher.subjectId }?.name ?: teacher.role
)
}