chore: unify runDB calls
This commit is contained in:
parent
55319c8c50
commit
5c56745042
@ -171,16 +171,16 @@ examAutoOccurrenceCalculateWidget tid ssh csh examn = do
|
|||||||
|
|
||||||
postEAutoOccurrenceR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html
|
postEAutoOccurrenceR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html
|
||||||
postEAutoOccurrenceR tid ssh csh examn = do
|
postEAutoOccurrenceR tid ssh csh examn = do
|
||||||
(Entity eId Exam{ examOccurrenceRule }, occurrences) <- runDB $ do
|
(Entity eId Exam{ examOccurrenceRule }, occurrences, participants) <- runDB $ do
|
||||||
exam@(Entity eId _) <- fetchExam tid ssh csh examn
|
exam@(Entity eId _) <- fetchExam tid ssh csh examn
|
||||||
occurrences <- selectList [ ExamOccurrenceExam ==. eId ] [ Asc ExamOccurrenceName ]
|
occurrences <- selectList [ ExamOccurrenceExam ==. eId ] [ Asc ExamOccurrenceName ]
|
||||||
return (exam, occurrences)
|
participants <- E.select . E.from $ \(registration `E.InnerJoin` user) -> do
|
||||||
|
|
||||||
|
|
||||||
participants <- runDB $ E.select . E.from $ \(registration `E.InnerJoin` user) -> do
|
|
||||||
E.on $ registration E.^. ExamRegistrationUser E.==. user E.^. UserId
|
E.on $ registration E.^. ExamRegistrationUser E.==. user E.^. UserId
|
||||||
E.where_ $ registration E.^. ExamRegistrationExam E.==. E.val eId
|
E.where_ $ registration E.^. ExamRegistrationExam E.==. E.val eId
|
||||||
return (user, registration)
|
return (user, registration)
|
||||||
|
return (exam, occurrences, participants)
|
||||||
|
|
||||||
|
|
||||||
let participants' = Map.fromList $ do
|
let participants' = Map.fromList $ do
|
||||||
(Entity uid userRec, Entity _ ExamRegistration{..}) <- participants
|
(Entity uid userRec, Entity _ ExamRegistration{..}) <- participants
|
||||||
return (uid, (userRec, examRegistrationOccurrence))
|
return (uid, (userRec, examRegistrationOccurrence))
|
||||||
|
|||||||
Reference in New Issue
Block a user