chore: unify runDB calls

This commit is contained in:
Wolfgang Witt 2021-03-29 13:03:38 +02:00 committed by Gregor Kleen
parent 55319c8c50
commit 5c56745042

View File

@ -171,16 +171,16 @@ examAutoOccurrenceCalculateWidget tid ssh csh examn = do
postEAutoOccurrenceR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html
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
occurrences <- selectList [ ExamOccurrenceExam ==. eId ] [ Asc ExamOccurrenceName ]
return (exam, occurrences)
participants <- runDB $ E.select . E.from $ \(registration `E.InnerJoin` user) -> do
participants <- E.select . E.from $ \(registration `E.InnerJoin` user) -> do
E.on $ registration E.^. ExamRegistrationUser E.==. user E.^. UserId
E.where_ $ registration E.^. ExamRegistrationExam E.==. E.val eId
return (user, registration)
return (exam, occurrences, participants)
let participants' = Map.fromList $ do
(Entity uid userRec, Entity _ ExamRegistration{..}) <- participants
return (uid, (userRec, examRegistrationOccurrence))