diff --git a/Handler/Shared.hs b/Handler/Shared.hs index 1baa3d6..b327ccd 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -317,9 +317,14 @@ thenCmp EQ o2 = o2 thenCmp o1 _ = o1 getMainTest :: [Entity Test] -> Entity Test -getMainTest tests = DL.maximumBy (\(Entity _ a) (Entity _ b) -> ( ((testName a) `compare` (testName b)) - `thenCmp` - ((fromMaybe 9999 $ testPriority b) `compare` (fromMaybe 9999 $ testPriority a)) ) ) tests +getMainTest tests = DL.maximumBy testComparator tests + +testComparator :: Entity Test -> Entity Test -> Ordering +testComparator (Entity _ a) (Entity _ b) = + ((testName a) `compare` (testName b)) + `thenCmp` + ((fromMaybe unknownPriority $ testPriority b) `compare` (fromMaybe unknownPriority $ testPriority a)) + where unknownPriority = 9999 formatFullScore :: Maybe Evaluation -> Text formatFullScore (Just evaluation) = fromMaybe "???" (T.pack <$> show <$> evaluationScore evaluation)