From c41e3b6bb39e842f8b3f7809c64804ad80aa9ed6 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel <> Date: Sat, 7 Nov 2020 20:40:11 +0100 Subject: [PATCH] fix(schedule): display opted-in exam occs without registration --- src/Utils/Schedule.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Utils/Schedule.hs b/src/Utils/Schedule.hs index 372fba5ca..ebcf4dd4f 100644 --- a/src/Utils/Schedule.hs +++ b/src/Utils/Schedule.hs @@ -52,11 +52,16 @@ fetchExamOccurrences muid ata now = E.select $ E.from $ \(course `E.InnerJoin` e E.&&. (E.exists $ E.from $ \examRegistration -> E.where_ $ examRegistration E.^. ExamRegistrationExam E.==. exam E.^. ExamId E.&&. E.just (examRegistration E.^. ExamRegistrationUser) E.==. E.val muid - E.&&. E.maybe E.true (\registrationOccurrence -> registrationOccurrence E.==. examOccurrence E.^. ExamOccurrenceId) (examRegistration E.^. ExamRegistrationOccurrence) -- if registered for a specific occurrence, get only this one, otherwise get every occurrence available + E.&&. E.maybe E.true (\registrationOccurrence -> hasExamOccurrenceDisplayOptIn examOccurrence E.||. registrationOccurrence E.==. examOccurrence E.^. ExamOccurrenceId) (examRegistration E.^. ExamRegistrationOccurrence) -- if registered for a specific occurrence, get only this one and occurrences with an opt-in, otherwise get every occurrence available ) ) ) return (course, exam, examOccurrence) + where + hasExamOccurrenceDisplayOptIn examOccurrence = E.exists . E.from $ \examOccurrenceScheduleOpt -> E.where_ $ + examOccurrenceScheduleOpt E.^. ExamOccurrenceScheduleOptExamOccurrence E.==. examOccurrence E.^. ExamOccurrenceId + E.&&. E.just (examOccurrenceScheduleOpt E.^. ExamOccurrenceScheduleOptUser) E.==. E.val muid + E.&&. examOccurrenceScheduleOpt E.^. ExamOccurrenceScheduleOptOpt courseEventShouldBeDisplayed :: Maybe UserId -> E.SqlExpr (Entity Course) -> E.SqlExpr (Entity CourseEvent) -> E.SqlExpr (E.Value Bool)