Merge pull request #45 from mtlstats/filter-game-stats

filter out players without points from game report
This commit is contained in:
Jonathan Lamothe 2019-12-02 15:20:03 -05:00 committed by GitHub
commit cb5f2d7d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -3,6 +3,7 @@
## current
- Bugfix: removed quotation marks from goalie names in report
- Allow lower case player names
- Don't show players without points in game report
## 0.7.0
- Shortened views to fit within 25 lines

View File

@ -125,7 +125,9 @@ gameStatsReport width s = let
Just (g, stats))
(M.toList $ gs^.gameGoalieStats)
in playerReport width "GAME" playerStats
criteria (_, ps) = psPoints ps > 0
in filteredPlayerReport width "GAME" criteria playerStats
++ [""]
++ goalieReport width goalieStats
@ -167,8 +169,18 @@ gameDate gs = fromMaybe "" $ do
Just $ m ++ " " ++ d ++ " " ++ y
playerReport :: Int -> String -> [(Player, PlayerStats)] -> [String]
playerReport width label ps = let
playerReport width label ps =
filteredPlayerReport width label (const True) ps
filteredPlayerReport
:: Int
-> String
-> ((Player, PlayerStats) -> Bool)
-> [(Player, PlayerStats)]
-> [String]
filteredPlayerReport width label criteria ps = let
tStats = foldl addPlayerStats newPlayerStats $ map snd ps
fps = filter criteria ps
rHeader =
[ centre width (label ++ " STATISTICS")
@ -196,7 +208,7 @@ playerReport width label ps = let
[ CellText $ show (p^.pNumber) ++ " "
, CellText $ p^.pName
] ++ statsCells stats)
ps
fps
separator = replicate 2 (CellText "") ++ replicate 4 (CellFill '-')