From f1227da9caaa328452ff3bb6519225c3cf6d6638 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sun, 15 Dec 2019 13:19:12 -0500 Subject: [PATCH 1/2] sort players in YTD/lifetime reports by points --- ChangeLog.md | 1 + src/Mtlstats/Report.hs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7603d9e..e5673a8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ - Bugfix: Display lifetime stats in report, not YTD - Force expected capitalization on player/goalie names - Don't show lifetime totals in report +- Sort players in YTD and lifetime reports by points ## 0.8.0 - Bugfix: removed quotation marks from goalie names in report diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 323ae92..074be88 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -21,6 +21,7 @@ along with this program. If not, see . module Mtlstats.Report (report, gameDate) where +import Data.List (sortOn) import qualified Data.Map as M import Data.Maybe (fromMaybe, mapMaybe) import Lens.Micro ((^.)) @@ -135,7 +136,8 @@ yearToDateStatsReport :: Int -> ProgState -> [String] yearToDateStatsReport width s = let db = s^.database - playerStats = map (\p -> (p, p^.pYtd)) + playerStats = sortOn (psPoints . snd) + $ map (\p -> (p, p^.pYtd)) $ filter playerIsActive $ db^.dbPlayers @@ -151,7 +153,8 @@ lifetimeStatsReport :: Int -> ProgState -> [String] lifetimeStatsReport width s = let db = s^.database - playerStats = map (\p -> (p, p^.pLifetime)) + playerStats = sortOn (psPoints . snd) + $ map (\p -> (p, p^.pLifetime)) $ db^.dbPlayers goalieStats = map (\g -> (g, g^.gLifetime)) From 2f06fd221d6805ace4b4ae50144bee7293f9e402 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sun, 15 Dec 2019 13:26:22 -0500 Subject: [PATCH 2/2] sort descending --- src/Mtlstats/Report.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 074be88..4f4684f 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -136,7 +136,8 @@ yearToDateStatsReport :: Int -> ProgState -> [String] yearToDateStatsReport width s = let db = s^.database - playerStats = sortOn (psPoints . snd) + playerStats = reverse + $ sortOn (psPoints . snd) $ map (\p -> (p, p^.pYtd)) $ filter playerIsActive $ db^.dbPlayers @@ -153,7 +154,8 @@ lifetimeStatsReport :: Int -> ProgState -> [String] lifetimeStatsReport width s = let db = s^.database - playerStats = sortOn (psPoints . snd) + playerStats = reverse + $ sortOn (psPoints . snd) $ map (\p -> (p, p^.pLifetime)) $ db^.dbPlayers