[Vulcan/Hebe] Add filtering data by current school year.

This commit is contained in:
Kuba Szczodrzyński 2021-02-22 22:54:13 +01:00
parent b599d679c4
commit 30aeb70647
4 changed files with 12 additions and 0 deletions

View File

@ -156,6 +156,12 @@ open class VulcanHebe(open val data: DataVulcan, open val lastSync: Long?) {
} ?: false } ?: false
} }
fun isCurrentYear(dateTime: Long): Boolean {
return profile?.let { profile ->
return@let profile.dateSemester1Start.inMillis >= dateTime
} ?: false
}
inline fun <reified T> apiRequest( inline fun <reified T> apiRequest(
tag: String, tag: String,
endpoint: String, endpoint: String,

View File

@ -40,6 +40,8 @@ class VulcanHebeExams(
?: -1 ?: -1
val topic = exam.getString("Content")?.trim() ?: "" val topic = exam.getString("Content")?.trim() ?: ""
if (!isCurrentYear(eventDate)) return@forEach
val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate) val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate)
val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime

View File

@ -38,6 +38,8 @@ class VulcanHebeHomework(
val teamId = data.teamClass?.id ?: -1 val teamId = data.teamClass?.id ?: -1
val topic = exam.getString("Content")?.trim() ?: "" val topic = exam.getString("Content")?.trim() ?: ""
if (!isCurrentYear(eventDate)) return@forEach
val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate) val lessonList = data.db.timetableDao().getAllForDateNow(profileId, eventDate)
val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime val startTime = lessonList.firstOrNull { it.subjectId == subjectId }?.startTime

View File

@ -80,6 +80,8 @@ class VulcanHebeMessages(
val sentDate = getDateTime(message, "DateSent") val sentDate = getDateTime(message, "DateSent")
val readDate = getDateTime(message, "DateRead", default = 0) val readDate = getDateTime(message, "DateRead", default = 0)
if (!isCurrentYear(sentDate)) return@forEach
val messageObject = Message( val messageObject = Message(
profileId = profileId, profileId = profileId,
id = id, id = id,