[APIv2/Timetable] Fix lesson changes metadata.

This commit is contained in:
Kacper Ziubryniewicz 2019-11-24 10:36:20 +01:00
parent 19bc2b8b37
commit f689f4d427
4 changed files with 26 additions and 18 deletions

View File

@ -28,7 +28,7 @@ class IdziennikWebTimetable(override val data: DataIdziennik,
private const val TAG = "IdziennikWebTimetable" private const val TAG = "IdziennikWebTimetable"
} }
init { init { data.profile?.also { profile ->
val currentWeekStart = Week.getWeekStart() val currentWeekStart = Week.getWeekStart()
if (Date.getToday().weekDay > 4) { if (Date.getToday().weekDay > 4) {
@ -153,13 +153,15 @@ class IdziennikWebTimetable(override val data: DataIdziennik,
dates.add(lessonDate.value) dates.add(lessonDate.value)
lessons.add(lessonObject) lessons.add(lessonObject)
val seen = profile.empty || lessonDate < Date.getToday()
if (lessonObject.type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { if (lessonObject.type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) {
data.metadataList.add(Metadata( data.metadataList.add(Metadata(
profileId, profileId,
Metadata.TYPE_LESSON_CHANGE, Metadata.TYPE_LESSON_CHANGE,
lessonObject.id, lessonObject.id,
profile?.empty ?: false, seen,
profile?.empty ?: false, seen,
System.currentTimeMillis() System.currentTimeMillis()
)) ))
} }
@ -185,5 +187,5 @@ class IdziennikWebTimetable(override val data: DataIdziennik,
data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_TIMETABLE, SYNC_ALWAYS) data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_TIMETABLE, SYNC_ALWAYS)
onSuccess() onSuccess()
} }
} }}
} }

View File

@ -75,7 +75,7 @@ class LibrusApiTimetables(override val data: DataLibrus,
} }
} }
private fun parseLesson(lessonDate: Date, lesson: JsonObject) { private fun parseLesson(lessonDate: Date, lesson: JsonObject) { data.profile?.also { profile ->
val isSubstitution = lesson.getBoolean("IsSubstitutionClass") ?: false val isSubstitution = lesson.getBoolean("IsSubstitutionClass") ?: false
val isCancelled = lesson.getBoolean("IsCanceled") ?: false val isCancelled = lesson.getBoolean("IsCanceled") ?: false
@ -184,17 +184,19 @@ class LibrusApiTimetables(override val data: DataLibrus,
} }
} }
if (lessonObject.type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { val seen = profile.empty || lessonDate < Date.getToday()
if (lessonObject.type != Lesson.TYPE_NORMAL) {
data.metadataList.add( data.metadataList.add(
Metadata( Metadata(
data.profileId, profileId,
Metadata.TYPE_LESSON_CHANGE, Metadata.TYPE_LESSON_CHANGE,
lessonObject.id, lessonObject.id,
data.profile?.empty ?: false, seen,
data.profile?.empty ?: false, seen,
System.currentTimeMillis() System.currentTimeMillis()
)) ))
} }
data.lessonNewList.add(lessonObject) data.lessonNewList.add(lessonObject)
} }}
} }

View File

@ -14,7 +14,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date
import pl.szczodrzynski.edziennik.utils.models.Time import pl.szczodrzynski.edziennik.utils.models.Time
class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) { class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
init { init { data.profile?.also { profile ->
val lessons = rows.filterNot { it.isEmpty() }.map { it.split("|") } val lessons = rows.filterNot { it.isEmpty() }.map { it.split("|") }
val dataStart = Date.getToday() val dataStart = Date.getToday()
@ -75,14 +75,16 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
} }
} }
if (it.type != Lesson.TYPE_NORMAL && date >= Date.getToday()) { val seen = profile.empty || date < Date.getToday()
if (it.type != Lesson.TYPE_NORMAL) {
data.metadataList.add( data.metadataList.add(
Metadata( Metadata(
data.profileId, data.profileId,
Metadata.TYPE_LESSON_CHANGE, Metadata.TYPE_LESSON_CHANGE,
it.id, it.id,
data.profile?.empty ?: false, seen,
data.profile?.empty ?: false, seen,
System.currentTimeMillis() System.currentTimeMillis()
)) ))
} }
@ -194,5 +196,5 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List<String>) {
} }
} }
}*/ }*/
} }}
} }

View File

@ -172,13 +172,15 @@ class VulcanApiTimetable(override val data: DataVulcan, val onSuccess: () -> Uni
} }
} }
if (type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { val seen = profile.empty || lessonDate < Date.getToday()
if (type != Lesson.TYPE_NORMAL) {
data.metadataList.add(Metadata( data.metadataList.add(Metadata(
profileId, profileId,
Metadata.TYPE_LESSON_CHANGE, Metadata.TYPE_LESSON_CHANGE,
id, id,
profile.empty, seen,
profile.empty, seen,
System.currentTimeMillis() System.currentTimeMillis()
)) ))
} }