feat(schedule): account for display default for tutorials
This commit is contained in:
parent
e21536f85d
commit
5e0737d1b1
@ -31,9 +31,10 @@ fetchCourseEvents muid ata now = E.select $ E.from $ \(course `E.InnerJoin` cour
|
||||
fetchTutorials :: MonadHandler m => Maybe UserId -> AuthTagActive -> UTCTime -> ReaderT SqlBackend m [ScheduleTutorialInfo]
|
||||
fetchTutorials muid ata now = E.select $ E.from $ \(course `E.InnerJoin` tutorial) -> do
|
||||
E.on $ course E.^. CourseId E.==. tutorial E.^. TutorialCourse
|
||||
E.where_ $ mayViewCourse muid ata now course Nothing -- should not be necessary, but let's be on the safe side
|
||||
E.&&. ( isTutorialTutor muid ata (tutorial E.^. TutorialId)
|
||||
E.||. isTutorialParticipant muid ata (tutorial E.^. TutorialId)
|
||||
E.where_ $ tutorialShouldBeDisplayed muid course tutorial
|
||||
E.&&. mayViewCourse muid ata now course Nothing -- should not be necessary, but let's be on the safe side
|
||||
E.&&. ( isTutorialTutor muid ata (tutorial E.^. TutorialId)
|
||||
E.||. isTutorialParticipant muid ata (tutorial E.^. TutorialId)
|
||||
)
|
||||
return (course, tutorial)
|
||||
|
||||
@ -62,6 +63,14 @@ courseEventShouldBeDisplayed :: Maybe UserId -> E.SqlExpr (Entity Course) -> E.S
|
||||
courseEventShouldBeDisplayed (Just uid) _course _courseEvent = E.exists . E.from $ \user ->
|
||||
E.where_ $ user E.^. UserId E.==. E.val uid
|
||||
E.&&. ( -- TODO: also check whether there is a display opt-in/out for this course or course event
|
||||
user E.^. UserScheduleNewCoursesDisplayDefault
|
||||
user E.^. UserScheduleOccurrenceDisplayDefault
|
||||
)
|
||||
courseEventShouldBeDisplayed _ _ _ = E.false
|
||||
|
||||
tutorialShouldBeDisplayed :: Maybe UserId -> E.SqlExpr (Entity Course) -> E.SqlExpr (Entity Tutorial) -> E.SqlExpr (E.Value Bool)
|
||||
tutorialShouldBeDisplayed (Just uid) _course _tutorial = E.exists . E.from $ \user ->
|
||||
E.where_ $ user E.^. UserId E.==. E.val uid
|
||||
E.&&. ( -- TODO: also check whether there is a display opt-in/out for this course or tutorial
|
||||
user E.^. UserScheduleOccurrenceDisplayDefault
|
||||
)
|
||||
tutorialShouldBeDisplayed _ _ _ = E.false
|
||||
|
||||
Reference in New Issue
Block a user