From 5c56745042cde34ae207298cb3a4c9591672a8bc Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Mon, 29 Mar 2021 13:03:38 +0200 Subject: [PATCH] chore: unify runDB calls --- src/Handler/Exam/AutoOccurrence.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Handler/Exam/AutoOccurrence.hs b/src/Handler/Exam/AutoOccurrence.hs index a1e10a38e..df036163b 100644 --- a/src/Handler/Exam/AutoOccurrence.hs +++ b/src/Handler/Exam/AutoOccurrence.hs @@ -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))