[APIv2/Librus] Fix looking for the lesson in getting homework.

This commit is contained in:
Kacper Ziubryniewicz 2019-11-25 22:53:37 +01:00
parent 6892832fff
commit d17d2c8417

View File

@ -56,16 +56,16 @@ class LibrusSynergiaHomework(override val data: DataLibrus, val onSuccess: () ->
val id = "/podglad/([0-9]+)'".toRegex().find( val id = "/podglad/([0-9]+)'".toRegex().find(
elements[9].select("input").attr("onclick") elements[9].select("input").attr("onclick")
)?.get(1)?.toLong() ?: return@forEachIndexed )?.get(1)?.toLong() ?: return@forEachIndexed
val startTime = data.lessonList.singleOrNull {
it.weekDay == eventDate.weekDay && it.subjectId == subjectId val lessons = data.db.timetableDao().getForDateNow(profileId, eventDate)
}?.startTime val startTime = lessons.firstOrNull { it.subjectId == subjectId }?.startTime
val moreInfo = graphElements[2 * i + 1].select("td[title]") val moreInfo = graphElements[2 * i + 1].select("td[title]")
.attr("title").trim() .attr("title").trim()
val description = "Treść: (.*)".toRegex(RegexOption.DOT_MATCHES_ALL).find(moreInfo) val description = "Treść: (.*)".toRegex(RegexOption.DOT_MATCHES_ALL).find(moreInfo)
?.get(1)?.replace("<br.*/>".toRegex(), "\n")?.trim() ?.get(1)?.replace("<br.*/>".toRegex(), "\n")?.trim()
val notified = when (profile?.empty) { val seen = when (profile?.empty) {
true -> true true -> true
else -> eventDate < Date.getToday() else -> eventDate < Date.getToday()
} }
@ -89,8 +89,8 @@ class LibrusSynergiaHomework(override val data: DataLibrus, val onSuccess: () ->
profileId, profileId,
Metadata.TYPE_HOMEWORK, Metadata.TYPE_HOMEWORK,
id, id,
notified, seen,
notified, seen,
addedDate addedDate
)) ))
} }