diff --git a/ChangeLog.md b/ChangeLog.md index da9ccf2..eb5f099 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ ## current - Edit lifetime stats on new player/goalie creation - Sort goalies by minutes played +- Subsort players by lifetime points ## 0.11.0 - Added active flag to players/goalies diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 54bf69d..f9b5ad4 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -117,7 +117,7 @@ gameStatsReport width s = let gs = s^.progMode.gameStateL db = s^.database - playerStats = mapMaybe + playerStats = sortPlayers $ mapMaybe (\(pid, stats) -> do p <- nth pid $ db^.dbPlayers Just (p, stats)) @@ -139,7 +139,7 @@ yearToDateStatsReport :: Int -> ProgState -> [String] yearToDateStatsReport width s = let db = s^.database - playerStats = sortOn (Down . psPoints . snd) + playerStats = sortPlayers $ map (\p -> (p, p^.pYtd)) $ filter playerIsActive $ db^.dbPlayers @@ -156,7 +156,7 @@ lifetimeStatsReport :: Int -> ProgState -> [String] lifetimeStatsReport width s = let db = s^.database - playerStats = sortOn (Down . psPoints . snd) + playerStats = sortPlayers $ map (\p -> (p, p^.pLifetime)) $ db^.dbPlayers @@ -335,6 +335,10 @@ gameGoalieReport width goalieData = let $ complexTable ([right, left] ++ repeat right) $ header : body +sortPlayers :: [(Player, PlayerStats)] -> [(Player, PlayerStats)] +sortPlayers = sortOn $ Down . \(p, ps) -> + (psPoints ps, psPoints $ p^.pLifetime) + sortGoalies :: [(Goalie, GoalieStats)] -> [(Goalie, GoalieStats)] sortGoalies = sortOn $ Down . \(g, gs) -> (gs^.gsMinsPlayed, g^.gLifetime.gsMinsPlayed)