From 30aeb70647312d07e2998ce2f82a4be4727dd458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 22 Feb 2021 22:54:13 +0100 Subject: [PATCH] [Vulcan/Hebe] Add filtering data by current school year. --- .../edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt | 6 ++++++ .../data/api/edziennik/vulcan/data/hebe/VulcanHebeExams.kt | 2 ++ .../api/edziennik/vulcan/data/hebe/VulcanHebeHomework.kt | 2 ++ .../api/edziennik/vulcan/data/hebe/VulcanHebeMessages.kt | 2 ++ 4 files changed, 12 insertions(+) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt index ba943388..929a2230 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/VulcanHebe.kt @@ -156,6 +156,12 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) { } ?: false } + fun isCurrentYear(dateTime: Long): Boolean { + return profile?.let { profile -> + return@let profile.dateSemester1Start.inMillis >= dateTime + } ?: false + } + inline fun apiRequest( tag: String, endpoint: String, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeExams.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeExams.kt index 52fbead2..64b52e2b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeExams.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeExams.kt @@ -40,6 +40,8 @@ class VulcanHebeExams( ?: -1 val topic = exam.getString("Content")?.trim() ?: "" + if (!isCurrentYear(eventDate)) return@forEach + val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate) val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeHomework.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeHomework.kt index 2a746e71..fb6f2d6d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeHomework.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeHomework.kt @@ -38,6 +38,8 @@ class VulcanHebeHomework( val teamId = data.teamClass?.id ?: -1 val topic = exam.getString("Content")?.trim() ?: "" + if (!isCurrentYear(eventDate)) return@forEach + val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate) val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeMessages.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeMessages.kt index fcaa30eb..1e9a3b09 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeMessages.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/vulcan/data/hebe/VulcanHebeMessages.kt @@ -80,6 +80,8 @@ class VulcanHebeMessages( val sentDate = getDateTime(message, "DateSent") val readDate = getDateTime(message, "DateRead", default = 0) + if (!isCurrentYear(sentDate)) return@forEach + val messageObject = Message( profileId = profileId, id = id,