From bdbe0131d79ef6eeb3ea0cbbba7f9781c3c8253f Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 31 Jan 2020 21:54:32 -0500 Subject: [PATCH] sort goalies by number of minutes played --- ChangeLog.md | 1 + src/Mtlstats/Report.hs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 22040fb..da9ccf2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## current - Edit lifetime stats on new player/goalie creation +- Sort goalies by minutes played ## 0.11.0 - Added active flag to players/goalies diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 9ca1eae..54bf69d 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -261,8 +261,10 @@ goalieReport width showTotals lineNumbers goalieData = let then "GOALTENDING TOTALS" else "" + goalieData' = sortGoalies goalieData + tData = foldl addGoalieStats newGoalieStats - $ map snd goalieData + $ map snd goalieData' header = [ CellText "NO." @@ -287,7 +289,7 @@ goalieReport width showTotals lineNumbers goalieData = let [ CellText $ show (goalie^.gNumber) ++ " " , CellText $ goalieName goalie ] ++ rowCells stats) - goalieData + goalieData' separator = replicate 2 (CellText "") @@ -309,6 +311,8 @@ goalieReport width showTotals lineNumbers goalieData = let gameGoalieReport :: Int -> [(Goalie, GoalieStats)] -> [String] gameGoalieReport width goalieData = let + goalieData' = sortGoalies goalieData + header = [ CellText "NO." , CellText "GOALTENDER" @@ -325,8 +329,12 @@ gameGoalieReport width goalieData = let , CellText $ show $ stats^.gsGoalsAllowed , CellText $ showFloating $ gsAverage stats ]) - goalieData + goalieData' in map (centre width) $ complexTable ([right, left] ++ repeat right) $ header : body + +sortGoalies :: [(Goalie, GoalieStats)] -> [(Goalie, GoalieStats)] +sortGoalies = sortOn $ Down . \(g, gs) -> + (gs^.gsMinsPlayed, g^.gLifetime.gsMinsPlayed)