From a7abe1231a15eb208e0b4b54e141c0fc1c2bb140 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel <> Date: Mon, 10 Aug 2020 12:40:43 +0200 Subject: [PATCH] refactor(course-visibility): remove unnecessary allocation checks --- src/Handler/Allocation/Show.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Handler/Allocation/Show.hs b/src/Handler/Allocation/Show.hs index acdc43714..08cd70d32 100644 --- a/src/Handler/Allocation/Show.hs +++ b/src/Handler/Allocation/Show.hs @@ -34,7 +34,7 @@ getAShowR tid ssh ash = do resultCourseVisible = _5 . _Value (Entity aId Allocation{..}, School{..}, isAnyLecturer, courses, registration) <- runDB $ do - alloc@(Entity aId Allocation{allocationSchool,allocationRegisterFrom,allocationRegisterTo}) <- getBy404 $ TermSchoolAllocationShort tid ssh ash + alloc@(Entity aId Allocation{allocationSchool}) <- getBy404 $ TermSchoolAllocationShort tid ssh ash school <- getJust allocationSchool courses <- E.select . E.from $ \((allocationCourse `E.InnerJoin` course) `E.LeftOuterJoin` courseApplication `E.LeftOuterJoin` registration) -> do @@ -46,14 +46,8 @@ getAShowR tid ssh ash = do E.&&. courseApplication E.?. CourseApplicationAllocation E.==. E.just (E.just $ E.val aId) E.on $ allocationCourse E.^. AllocationCourseCourse E.==. course E.^. CourseId E.where_ $ allocationCourse E.^. AllocationCourseAllocation E.==. E.val aId - E.&&. (mayViewCourse muid ata now course (Just $ E.val aId) - E.||. E.isJust (courseApplication E.?. CourseApplicationId) - E.||. (E.isJust (E.val allocationRegisterFrom) - E.&&. E.val allocationRegisterFrom E.<=. E.val (Just now) - E.&&. (E.isNothing (E.val allocationRegisterTo) - E.||. E.val (Just now) E.<=. E.val allocationRegisterTo - ) - ) + E.&&. ( E.isJust (courseApplication E.?. CourseApplicationId) + E.||. mayViewCourse muid ata now course (Just $ E.val aId) ) E.orderBy [E.asc $ course E.^. CourseName] let hasTemplate = E.exists . E.from $ \courseAppInstructionFile ->