refactor(course-visibility): use E.maybe
This commit is contained in:
parent
29da6e2ac5
commit
06c4e0c2c3
@ -41,9 +41,10 @@ countCourses muid ata now addWhere allocation = E.subSelectCount . E.from $ \all
|
||||
)
|
||||
E.||. (E.isJust (allocation E.^. AllocationRegisterFrom)
|
||||
E.&&. allocation E.^. AllocationRegisterFrom E.<=. E.val (Just now)
|
||||
E.&&. (E.isNothing (allocation E.^. AllocationRegisterTo)
|
||||
E.||. E.val (Just now) E.<=. allocation E.^. AllocationRegisterTo
|
||||
)
|
||||
E.&&. E.maybe
|
||||
(E.val True)
|
||||
(\registerTo -> E.val now E.<=. registerTo)
|
||||
(allocation E.^. AllocationRegisterTo)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -80,10 +80,10 @@ courseIsVisible :: UTCTime -> E.SqlExpr (Entity Course) -> E.SqlExpr (E.Value Bo
|
||||
courseIsVisible now course =
|
||||
E.isJust (course E.^. CourseVisibleFrom)
|
||||
E.&&. course E.^. CourseVisibleFrom E.<=. E.val (Just now)
|
||||
E.&&. (
|
||||
E.isNothing (course E.^. CourseVisibleTo)
|
||||
E.||. E.val (Just now) E.<=. course E.^. CourseVisibleTo
|
||||
)
|
||||
E.&&. E.maybe
|
||||
(E.val True)
|
||||
(\visibleTo -> E.val now E.<=. visibleTo)
|
||||
(course E.^. CourseVisibleTo)
|
||||
|
||||
courseIsVisible' :: UTCTime -> Course -> Bool
|
||||
courseIsVisible' now Course{..} = NTop courseVisibleFrom <= now' && now' <= NTop courseVisibleTo
|
||||
|
||||
Loading…
Reference in New Issue
Block a user