Merge pull request #51 from mtlstats/sort-players

sort players in YTD/lifetime reports by points
This commit is contained in:
Jonathan Lamothe 2019-12-15 13:30:47 -05:00 committed by GitHub
commit 0ecf899b56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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,9 @@ yearToDateStatsReport :: Int -> ProgState -> [String]
yearToDateStatsReport width s = let
db = s^.database
playerStats = map (\p -> (p, p^.pYtd))
playerStats = reverse
$ sortOn (psPoints . snd)
$ map (\p -> (p, p^.pYtd))
$ filter playerIsActive
$ db^.dbPlayers
@ -151,7 +154,9 @@ lifetimeStatsReport :: Int -> ProgState -> [String]
lifetimeStatsReport width s = let
db = s^.database
playerStats = map (\p -> (p, p^.pLifetime))
playerStats = reverse
$ sortOn (psPoints . snd)
$ map (\p -> (p, p^.pLifetime))
$ db^.dbPlayers
goalieStats = map (\g -> (g, g^.gLifetime))