refactor: cleanup

This commit is contained in:
Gregor Kleen 2019-09-06 09:38:00 +02:00
parent 5fb6910a58
commit af9fe80bf5

View File

@ -76,16 +76,18 @@ writeSubmissionPlan :: Map SubmissionId (Maybe UserId)
) -- ^ Returns assigned and unassigned submissions; unassigned submissions occur only if no tutors have an assigned load ) -- ^ Returns assigned and unassigned submissions; unassigned submissions occur only if no tutors have an assigned load
writeSubmissionPlan newSubmissionData = do writeSubmissionPlan newSubmissionData = do
now <- liftIO getCurrentTime now <- liftIO getCurrentTime
execWriterT . forM_ (Map.toList newSubmissionData) $ \(subId, mCorrector) -> case mCorrector of execWriterT . forM_ (Map.toList newSubmissionData) $ \(subId, mCorrector) -> if
Just _ -> do | is _Just mCorrector
sub <- lift $ getJust subId -> do
lift $ update subId [ SubmissionRatingBy =. mCorrector lift $ do
, SubmissionRatingAssigned =. Just now Submission{submissionSheet} <- updateGet subId
] [ SubmissionRatingBy =. mCorrector
lift $ audit $ TransactionSubmissionEdit subId $ sub ^. _submissionSheet , SubmissionRatingAssigned =. Just now
tell (Set.singleton subId, mempty) ]
Nothing -> audit $ TransactionSubmissionEdit subId submissionSheet
tell (mempty, Set.singleton subId) tell (Set.singleton subId, mempty)
| otherwise
-> tell (mempty, Set.singleton subId)
-- | Compute a map that shows which submissions ought the be assigned to each corrector according to sheet corrector loads, but does not alter database yet! -- | Compute a map that shows which submissions ought the be assigned to each corrector according to sheet corrector loads, but does not alter database yet!
-- May throw an exception if there are no suitable correctors -- May throw an exception if there are no suitable correctors
@ -569,10 +571,10 @@ sinkSubmission userId mExists isUpdate = do
getSheetId :: MonadIO m => ReaderT SqlBackend m SheetId getSheetId :: MonadIO m => ReaderT SqlBackend m SheetId
getSheetId = case mExists of getSheetId = case mExists of
Left shid -> return shid Left shid
Right _ -> do -> return shid
Just Submission{submissionSheet} <- E.get submissionId -- there must have been a submission, otherwise mExists would have been Left shid Right _
return submissionSheet -> submissionSheet <$> getJust submissionId -- there must have been a submission, otherwise mExists would have been Left shid
finalize :: SubmissionSinkState -> YesodJobDB UniWorX () finalize :: SubmissionSinkState -> YesodJobDB UniWorX ()
finalize SubmissionSinkState{..} = do finalize SubmissionSinkState{..} = do