Don't attempt to dequeue corrector who isn't (also) proportional
This commit is contained in:
parent
6d7522410a
commit
99d112b31c
@ -50,7 +50,7 @@ instance Exception AssignSubmissionException
|
|||||||
assignSubmissions :: SheetId -> YesodDB UniWorX ()
|
assignSubmissions :: SheetId -> YesodDB UniWorX ()
|
||||||
assignSubmissions sid = do
|
assignSubmissions sid = do
|
||||||
correctors <- selectList [SheetCorrectorSheet ==. sid] []
|
correctors <- selectList [SheetCorrectorSheet ==. sid] []
|
||||||
let (corrsGroup, corrsProp) = partition (is _ByTutorial . sheetCorrectorLoad . entityVal) correctors
|
let (corrsGroup, (filterNonPositive -> corrsProp)) = partition (is _ByTutorial . sheetCorrectorLoad . entityVal) correctors
|
||||||
countsToLoad' :: UserId -> Bool
|
countsToLoad' :: UserId -> Bool
|
||||||
countsToLoad' uid = fromMaybe (error "Called `countsToLoad'` on entity not element of `corrsGroup`") $ listToMaybe [sheetCorrectorLoad | Entity _ SheetCorrector{..} <- corrsGroup, sheetCorrectorUser == uid] >>= preview _ByTutorial
|
countsToLoad' uid = fromMaybe (error "Called `countsToLoad'` on entity not element of `corrsGroup`") $ listToMaybe [sheetCorrectorLoad | Entity _ SheetCorrector{..} <- corrsGroup, sheetCorrectorUser == uid] >>= preview _ByTutorial
|
||||||
subs <- E.select . E.from $ \(submission `E.LeftOuterJoin` user) -> do
|
subs <- E.select . E.from $ \(submission `E.LeftOuterJoin` user) -> do
|
||||||
@ -74,7 +74,7 @@ assignSubmissions sid = do
|
|||||||
subTutor <- fmap fst . flip execStateT (Map.empty, queue) . forM_ (Map.toList subTutor') $ \case
|
subTutor <- fmap fst . flip execStateT (Map.empty, queue) . forM_ (Map.toList subTutor') $ \case
|
||||||
(smid, Just tutid) -> do
|
(smid, Just tutid) -> do
|
||||||
_1 %= Map.insert smid tutid
|
_1 %= Map.insert smid tutid
|
||||||
when (countsToLoad' tutid) $
|
when (any ((== tutid) . sheetCorrectorUser . entityVal) corrsProp && countsToLoad' tutid) $
|
||||||
_2 %= delFirst (Just tutid)
|
_2 %= delFirst (Just tutid)
|
||||||
(smid, Nothing) -> do
|
(smid, Nothing) -> do
|
||||||
(q:qs) <- use _2
|
(q:qs) <- use _2
|
||||||
@ -87,6 +87,8 @@ assignSubmissions sid = do
|
|||||||
|
|
||||||
return ()
|
return ()
|
||||||
where
|
where
|
||||||
|
filterNonPositive = filter $ (> 0) . load . sheetCorrectorLoad . entityVal
|
||||||
|
|
||||||
delFirst _ [] = []
|
delFirst _ [] = []
|
||||||
delFirst x (y:ys)
|
delFirst x (y:ys)
|
||||||
| x == y = ys
|
| x == y = ys
|
||||||
|
|||||||
Reference in New Issue
Block a user