refactor: cleanup
This commit is contained in:
parent
5fb6910a58
commit
af9fe80bf5
@ -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
|
||||
writeSubmissionPlan newSubmissionData = do
|
||||
now <- liftIO getCurrentTime
|
||||
execWriterT . forM_ (Map.toList newSubmissionData) $ \(subId, mCorrector) -> case mCorrector of
|
||||
Just _ -> do
|
||||
sub <- lift $ getJust subId
|
||||
lift $ update subId [ SubmissionRatingBy =. mCorrector
|
||||
, SubmissionRatingAssigned =. Just now
|
||||
]
|
||||
lift $ audit $ TransactionSubmissionEdit subId $ sub ^. _submissionSheet
|
||||
tell (Set.singleton subId, mempty)
|
||||
Nothing ->
|
||||
tell (mempty, Set.singleton subId)
|
||||
execWriterT . forM_ (Map.toList newSubmissionData) $ \(subId, mCorrector) -> if
|
||||
| is _Just mCorrector
|
||||
-> do
|
||||
lift $ do
|
||||
Submission{submissionSheet} <- updateGet subId
|
||||
[ SubmissionRatingBy =. mCorrector
|
||||
, SubmissionRatingAssigned =. Just now
|
||||
]
|
||||
audit $ TransactionSubmissionEdit subId submissionSheet
|
||||
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!
|
||||
-- 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 = case mExists of
|
||||
Left shid -> return shid
|
||||
Right _ -> do
|
||||
Just Submission{submissionSheet} <- E.get submissionId -- there must have been a submission, otherwise mExists would have been Left shid
|
||||
return submissionSheet
|
||||
Left shid
|
||||
-> return shid
|
||||
Right _
|
||||
-> submissionSheet <$> getJust submissionId -- there must have been a submission, otherwise mExists would have been Left shid
|
||||
|
||||
finalize :: SubmissionSinkState -> YesodJobDB UniWorX ()
|
||||
finalize SubmissionSinkState{..} = do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user