Filter empty teachers
This commit is contained in:
parent
e92a8d0e20
commit
433cd83357
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue