[APIv2/Mobidziennik] Make use of String.fixName()

This commit is contained in:
Kuba Szczodrzyński 2019-10-28 19:54:53 +01:00
parent debb0b1507
commit 5e90e9aa71
2 changed files with 9 additions and 6 deletions

View File

@ -8,7 +8,7 @@ import pl.szczodrzynski.edziennik.api.v2.mobidziennik.DataMobidziennik
import pl.szczodrzynski.edziennik.data.db.modules.lessons.Lesson
import pl.szczodrzynski.edziennik.data.db.modules.lessons.LessonChange
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
import pl.szczodrzynski.edziennik.fixWhiteSpaces
import pl.szczodrzynski.edziennik.fixName
import pl.szczodrzynski.edziennik.singleOrNull
class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
@ -26,7 +26,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
data.subjectList.singleOrNull { it.longName == lesson[5] }?.let {
lessonObject.subjectId = it.id
}
data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixWhiteSpaces() }?.let {
data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixName() }?.let {
lessonObject.teacherId = it.id
}
data.teamList.singleOrNull { it.name == lesson[8]+lesson[9] }?.let {
@ -52,7 +52,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
data.subjectList.singleOrNull { it.longName == lesson[5] }?.let {
lessonChange.subjectId = it.id
}
data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixWhiteSpaces() }?.let {
data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixName() }?.let {
lessonChange.teacherId = it.id
}
data.teamList.singleOrNull { it.name == lesson[8]+lesson[9] }?.let {

View File

@ -6,7 +6,7 @@ package pl.szczodrzynski.edziennik.api.v2.mobidziennik.data.api
import pl.szczodrzynski.edziennik.api.v2.mobidziennik.DataMobidziennik
import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher
import pl.szczodrzynski.edziennik.fixWhiteSpaces
import pl.szczodrzynski.edziennik.fixName
class MobidziennikApiUsers(val data: DataMobidziennik, rows: List<String>) {
init {
@ -15,9 +15,12 @@ class MobidziennikApiUsers(val data: DataMobidziennik, rows: List<String>) {
continue
val cols = row.split("|")
if (cols[1] != "*")
continue
val id = cols[0].toLong()
val name = cols[4].fixWhiteSpaces()
val surname = cols[5].fixWhiteSpaces()
val name = cols[4].fixName()
val surname = cols[5].fixName()
data.teachersMap.put(id, "$surname $name")
data.teacherList.put(id, Teacher(data.profileId, id, name, surname))