Skip to content

Commit

Permalink
fix: [ANDROAPP-5803] ignore deleted events on schedule creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Jan 9, 2024
1 parent cd0925e commit d08598a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ class EventDetailsRepository(
val activeEvents =
d2.eventModule().events().byEnrollmentUid().eq(enrollmentUid).byProgramStageUid()
.eq(programStageUid)
.byDeleted().isFalse
.orderByEventDate(RepositoryScope.OrderByDirection.DESC).blockingGet()
val scheduleEvents =
d2.eventModule().events().byEnrollmentUid().eq(enrollmentUid).byProgramStageUid()
.eq(programStageUid)
.byDeleted().isFalse
.orderByDueDate(RepositoryScope.OrderByDirection.DESC).blockingGet()

var activeDate: Date? = null
Expand All @@ -88,7 +90,12 @@ class EventDetailsRepository(
}
if (scheduleEvents.isNotEmpty()) scheduleDate = scheduleEvents[0].dueDate()

return activeDate ?: scheduleDate
return when {
scheduleDate == null -> activeDate
activeDate == null -> scheduleDate
activeDate.before(scheduleDate) -> scheduleDate
else -> activeDate
}
}

fun hasAccessDataWrite(): Boolean {
Expand Down

0 comments on commit d08598a

Please sign in to comment.