chore: filter out all empty/prefilled rooms

They might produce unnecessary null-results
This commit is contained in:
Wolfgang Witt 2021-02-06 22:44:53 +01:00 committed by Wolfgang Witt
parent 48ee67f6d6
commit 479f4326b2

View File

@ -311,14 +311,13 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences
occurrences' :: Map ExamOccurrenceId Natural occurrences' :: Map ExamOccurrenceId Natural
-- ^ reduce room capacity for every pre-assigned user by 1 -- ^ reduce room capacity for every pre-assigned user by 1
occurrences' = foldl' (flip $ Map.update predToPositive) occurrences $ Map.mapMaybe snd users -- also remove empty/pre-filled rooms
-- FIXME what about capacity-0 in occurrences? occurrences' = foldl' (flip $ Map.update predToPositive) (Map.filter (> 0) occurrences) $ Map.mapMaybe snd users
-- what if the first word is too big for the first room?
where predToPositive :: Natural -> Maybe Natural
predToPositive :: Natural -> Maybe Natural predToPositive 0 = Nothing
predToPositive 0 = Nothing predToPositive 1 = Nothing
predToPositive 1 = Nothing predToPositive n = Just $ pred n
predToPositive n = Just $ pred n
occurrences'' :: [(ExamOccurrenceId, Natural)] occurrences'' :: [(ExamOccurrenceId, Natural)]
-- ^ Minimise number of occurrences used -- ^ Minimise number of occurrences used