Avoid divide by zero

This commit is contained in:
Gregor Kleen 2019-01-30 10:07:31 +01:00
parent 78fc27dc04
commit 2bea5435bf

View File

@ -130,7 +130,9 @@ assignSubmissions sid restriction = do
props = getSum $ foldMap (Sum . fst) assignments
toDeficit' (prop, assigned) = let
target = round $ fromInteger assigned' * (prop / props)
target
| props == 0 = 0
| otherwise = round $ fromInteger assigned' * (prop / props)
in target - assigned
$logDebugS "assignSubmissions" $ "Previous submissions: " <> tshow prevSubs'