Merge pull request #69 from mtlstats/sort-goalies

sort goalies by number of minutes played
This commit is contained in:
Jonathan Lamothe 2020-01-31 21:59:48 -05:00 committed by GitHub
commit d94c6a588e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -2,6 +2,7 @@
## current ## current
- Edit lifetime stats on new player/goalie creation - Edit lifetime stats on new player/goalie creation
- Sort goalies by minutes played
## 0.11.0 ## 0.11.0
- Added active flag to players/goalies - Added active flag to players/goalies

View File

@ -261,8 +261,10 @@ goalieReport width showTotals lineNumbers goalieData = let
then "GOALTENDING TOTALS" then "GOALTENDING TOTALS"
else "" else ""
goalieData' = sortGoalies goalieData
tData = foldl addGoalieStats newGoalieStats tData = foldl addGoalieStats newGoalieStats
$ map snd goalieData $ map snd goalieData'
header = header =
[ CellText "NO." [ CellText "NO."
@ -287,7 +289,7 @@ goalieReport width showTotals lineNumbers goalieData = let
[ CellText $ show (goalie^.gNumber) ++ " " [ CellText $ show (goalie^.gNumber) ++ " "
, CellText $ goalieName goalie , CellText $ goalieName goalie
] ++ rowCells stats) ] ++ rowCells stats)
goalieData goalieData'
separator separator
= replicate 2 (CellText "") = replicate 2 (CellText "")
@ -309,6 +311,8 @@ goalieReport width showTotals lineNumbers goalieData = let
gameGoalieReport :: Int -> [(Goalie, GoalieStats)] -> [String] gameGoalieReport :: Int -> [(Goalie, GoalieStats)] -> [String]
gameGoalieReport width goalieData = let gameGoalieReport width goalieData = let
goalieData' = sortGoalies goalieData
header = header =
[ CellText "NO." [ CellText "NO."
, CellText "GOALTENDER" , CellText "GOALTENDER"
@ -325,8 +329,12 @@ gameGoalieReport width goalieData = let
, CellText $ show $ stats^.gsGoalsAllowed , CellText $ show $ stats^.gsGoalsAllowed
, CellText $ showFloating $ gsAverage stats , CellText $ showFloating $ gsAverage stats
]) ])
goalieData goalieData'
in map (centre width) in map (centre width)
$ complexTable ([right, left] ++ repeat right) $ complexTable ([right, left] ++ repeat right)
$ header : body $ header : body
sortGoalies :: [(Goalie, GoalieStats)] -> [(Goalie, GoalieStats)]
sortGoalies = sortOn $ Down . \(g, gs) ->
(gs^.gsMinsPlayed, g^.gLifetime.gsMinsPlayed)