Merge pull request #59 from mtlstats/line-numbers

add line numbers to lifetime player/goalie reports
This commit is contained in:
Jonathan Lamothe 2020-01-02 23:57:52 -05:00 committed by GitHub
commit 6c8ec21ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 9 deletions

View File

@ -6,6 +6,7 @@
- Return to correct edit menus after editing player stats - Return to correct edit menus after editing player stats
- Enabled batch editing of player/goalie YTD/lifetime stats - Enabled batch editing of player/goalie YTD/lifetime stats
- Bugfix: allow user to edit goalie shutouts - Bugfix: allow user to edit goalie shutouts
- Added line numbers to lifetime player/goalie reports
## 0.9.0 ## 0.9.0
- Bugfix: Display lifetime stats in report, not YTD - Bugfix: Display lifetime stats in report, not YTD

View File

@ -129,7 +129,7 @@ gameStatsReport width s = let
criteria (_, ps) = psPoints ps > 0 criteria (_, ps) = psPoints ps > 0
in filteredPlayerReport width "GAME" criteria True playerStats in filteredPlayerReport width "GAME" criteria True False playerStats
++ [""] ++ [""]
++ gameGoalieReport width goalieStats ++ gameGoalieReport width goalieStats
@ -146,9 +146,9 @@ yearToDateStatsReport width s = let
$ filter goalieIsActive $ filter goalieIsActive
$ db^.dbGoalies $ db^.dbGoalies
in playerReport width "YEAR TO DATE" True playerStats in playerReport width "YEAR TO DATE" True False playerStats
++ [""] ++ [""]
++ goalieReport width True goalieStats ++ goalieReport width True False goalieStats
lifetimeStatsReport :: Int -> ProgState -> [String] lifetimeStatsReport :: Int -> ProgState -> [String]
lifetimeStatsReport width s = let lifetimeStatsReport width s = let
@ -161,9 +161,9 @@ lifetimeStatsReport width s = let
goalieStats = map (\g -> (g, g^.gLifetime)) goalieStats = map (\g -> (g, g^.gLifetime))
$ db^.dbGoalies $ db^.dbGoalies
in playerReport width "LIFETIME" False playerStats in playerReport width "LIFETIME" False True playerStats
++ [""] ++ [""]
++ goalieReport width False goalieStats ++ goalieReport width False True goalieStats
gameDate :: GameState -> String gameDate :: GameState -> String
gameDate gs = fromMaybe "" $ do gameDate gs = fromMaybe "" $ do
@ -176,6 +176,7 @@ playerReport
:: Int :: Int
-> String -> String
-> Bool -> Bool
-> Bool
-> [(Player, PlayerStats)] -> [(Player, PlayerStats)]
-> [String] -> [String]
playerReport width label = playerReport width label =
@ -186,9 +187,10 @@ filteredPlayerReport
-> String -> String
-> ((Player, PlayerStats) -> Bool) -> ((Player, PlayerStats) -> Bool)
-> Bool -> Bool
-> Bool
-> [(Player, PlayerStats)] -> [(Player, PlayerStats)]
-> [String] -> [String]
filteredPlayerReport width label criteria showTotals ps = let filteredPlayerReport width label criteria showTotals lineNumbers ps = let
tStats = foldl addPlayerStats newPlayerStats $ map snd ps tStats = foldl addPlayerStats newPlayerStats $ map snd ps
criteria' = (&&) <$> criteria <*> \(p, _) -> p^.pNumber /= 0 criteria' = (&&) <$> criteria <*> \(p, _) -> p^.pNumber /= 0
fps = filter criteria' ps fps = filter criteria' ps
@ -232,8 +234,13 @@ filteredPlayerReport width label criteria showTotals ps = let
then label ++ " TOTALS" then label ++ " TOTALS"
else "" else ""
lnOverlay = if lineNumbers
then "" : [right 2 $ show x | x <- [(1 :: Int)..]]
else repeat ""
table = overlayLast olayText table = overlayLast olayText
$ map (centre width) $ map (\(ln, line) -> overlay ln $ centre width line)
$ zip lnOverlay
$ complexTable ([right, left] ++ repeat right) $ complexTable ([right, left] ++ repeat right)
$ tHeader : body ++ if showTotals $ tHeader : body ++ if showTotals
then [separator, totals] then [separator, totals]
@ -244,9 +251,10 @@ filteredPlayerReport width label criteria showTotals ps = let
goalieReport goalieReport
:: Int :: Int
-> Bool -> Bool
-> Bool
-> [(Goalie, GoalieStats)] -> [(Goalie, GoalieStats)]
-> [String] -> [String]
goalieReport width showTotals goalieData = let goalieReport width showTotals lineNumbers goalieData = let
olayText = if showTotals olayText = if showTotals
then "GOALTENDING TOTALS" then "GOALTENDING TOTALS"
else "" else ""
@ -285,7 +293,12 @@ goalieReport width showTotals goalieData = let
summary = replicate 2 (CellText "") ++ rowCells tData summary = replicate 2 (CellText "") ++ rowCells tData
in map (centre width) lnOverlay = if lineNumbers
then "" : [right 2 $ show x | x <- [(1 :: Int)..]]
else repeat ""
in map (\(ln, line) -> overlay ln $ centre width line)
$ zip lnOverlay
$ overlayLast olayText $ overlayLast olayText
$ complexTable ([right, left] ++ repeat right) $ complexTable ([right, left] ++ repeat right)
$ header : body ++ if showTotals $ header : body ++ if showTotals