don't show totals in lifetime stats
This commit is contained in:
parent
84c487dba5
commit
2b9a21c28b
|
@ -3,6 +3,7 @@
|
|||
## current
|
||||
- Bugfix: Display lifetime stats in report, not YTD
|
||||
- Force expected capitalization on player/goalie names
|
||||
- Don't show lifetime totals in report
|
||||
|
||||
## 0.8.0
|
||||
- Bugfix: removed quotation marks from goalie names in report
|
||||
|
|
|
@ -26,6 +26,7 @@ module Mtlstats.Format
|
|||
, left
|
||||
, right
|
||||
, centre
|
||||
, padRight
|
||||
, overlay
|
||||
, month
|
||||
, labelTable
|
||||
|
@ -87,6 +88,16 @@ centre n str = let
|
|||
pad = replicate pLen ' '
|
||||
in take n $ pad ++ str ++ repeat ' '
|
||||
|
||||
-- | Pads text on the right with spaces to fit a minimum width
|
||||
padRight
|
||||
:: Int
|
||||
-- ^ The width to pad to
|
||||
-> String
|
||||
-- ^ The text to pad
|
||||
-> String
|
||||
padRight width str =
|
||||
overlay str $ replicate width ' '
|
||||
|
||||
-- | Overlays one string on top of another
|
||||
overlay
|
||||
:: String
|
||||
|
|
|
@ -127,7 +127,7 @@ gameStatsReport width s = let
|
|||
|
||||
criteria (_, ps) = psPoints ps > 0
|
||||
|
||||
in filteredPlayerReport width "GAME" criteria playerStats
|
||||
in filteredPlayerReport width "GAME" criteria True playerStats
|
||||
++ [""]
|
||||
++ gameGoalieReport width goalieStats
|
||||
|
||||
|
@ -143,9 +143,9 @@ yearToDateStatsReport width s = let
|
|||
$ filter goalieIsActive
|
||||
$ db^.dbGoalies
|
||||
|
||||
in playerReport width "YEAR TO DATE" playerStats
|
||||
in playerReport width "YEAR TO DATE" True playerStats
|
||||
++ [""]
|
||||
++ goalieReport width goalieStats
|
||||
++ goalieReport width True goalieStats
|
||||
|
||||
lifetimeStatsReport :: Int -> ProgState -> [String]
|
||||
lifetimeStatsReport width s = let
|
||||
|
@ -157,9 +157,9 @@ lifetimeStatsReport width s = let
|
|||
goalieStats = map (\g -> (g, g^.gLifetime))
|
||||
$ db^.dbGoalies
|
||||
|
||||
in playerReport width "LIFETIME" playerStats
|
||||
in playerReport width "LIFETIME" False playerStats
|
||||
++ [""]
|
||||
++ goalieReport width goalieStats
|
||||
++ goalieReport width False goalieStats
|
||||
|
||||
gameDate :: GameState -> String
|
||||
gameDate gs = fromMaybe "" $ do
|
||||
|
@ -168,7 +168,12 @@ gameDate gs = fromMaybe "" $ do
|
|||
d <- padNum 2 <$> gs^.gameDay
|
||||
Just $ m ++ " " ++ d ++ " " ++ y
|
||||
|
||||
playerReport :: Int -> String -> [(Player, PlayerStats)] -> [String]
|
||||
playerReport
|
||||
:: Int
|
||||
-> String
|
||||
-> Bool
|
||||
-> [(Player, PlayerStats)]
|
||||
-> [String]
|
||||
playerReport width label =
|
||||
filteredPlayerReport width label (const True)
|
||||
|
||||
|
@ -176,9 +181,10 @@ filteredPlayerReport
|
|||
:: Int
|
||||
-> String
|
||||
-> ((Player, PlayerStats) -> Bool)
|
||||
-> Bool
|
||||
-> [(Player, PlayerStats)]
|
||||
-> [String]
|
||||
filteredPlayerReport width label criteria ps = let
|
||||
filteredPlayerReport width label criteria showTotals ps = let
|
||||
tStats = foldl addPlayerStats newPlayerStats $ map snd ps
|
||||
fps = filter criteria ps
|
||||
|
||||
|
@ -217,23 +223,35 @@ filteredPlayerReport width label criteria ps = let
|
|||
, CellText ""
|
||||
] ++ statsCells tStats
|
||||
|
||||
table = overlayLast (label ++ " TOTALS")
|
||||
olayText = if showTotals
|
||||
then label ++ " TOTALS"
|
||||
else ""
|
||||
|
||||
table = overlayLast olayText
|
||||
$ map (centre width)
|
||||
$ complexTable ([right, left] ++ repeat right)
|
||||
$ tHeader : body ++ [separator, totals]
|
||||
$ tHeader : body ++ if showTotals
|
||||
then [separator, totals]
|
||||
else []
|
||||
|
||||
in rHeader ++ table
|
||||
|
||||
goalieReport :: Int -> [(Goalie, GoalieStats)] -> [String]
|
||||
goalieReport width goalieData = let
|
||||
olayText = "GOALTENDING TOTALS"
|
||||
goalieReport
|
||||
:: Int
|
||||
-> Bool
|
||||
-> [(Goalie, GoalieStats)]
|
||||
-> [String]
|
||||
goalieReport width showTotals goalieData = let
|
||||
olayText = if showTotals
|
||||
then "GOALTENDING TOTALS"
|
||||
else ""
|
||||
|
||||
tData = foldl addGoalieStats newGoalieStats
|
||||
$ map snd goalieData
|
||||
|
||||
header =
|
||||
[ CellText "NO."
|
||||
, CellText $ left (length olayText) "GOALTENDER"
|
||||
, CellText $ padRight (length olayText) "GOALTENDER"
|
||||
, CellText "GP"
|
||||
, CellText " MIN"
|
||||
, CellText " GA"
|
||||
|
@ -265,7 +283,9 @@ goalieReport width goalieData = let
|
|||
in map (centre width)
|
||||
$ overlayLast olayText
|
||||
$ complexTable ([right, left] ++ repeat right)
|
||||
$ header : body ++ [separator, summary]
|
||||
$ header : body ++ if showTotals
|
||||
then [separator, summary]
|
||||
else []
|
||||
|
||||
gameGoalieReport :: Int -> [(Goalie, GoalieStats)] -> [String]
|
||||
gameGoalieReport width goalieData = let
|
||||
|
|
|
@ -33,6 +33,7 @@ spec = describe "Mtlstats.Format" $ do
|
|||
leftSpec
|
||||
rightSpec
|
||||
centreSpec
|
||||
padRightSpec
|
||||
overlaySpec
|
||||
monthSpec
|
||||
labelTableSpec
|
||||
|
@ -98,6 +99,16 @@ centreSpec = describe "centre" $ do
|
|||
it "should truncate the text" $
|
||||
centre 2 "foo" `shouldBe` "fo"
|
||||
|
||||
padRightSpec :: Spec
|
||||
padRightSpec = describe "padRight" $ mapM_
|
||||
(\(label, width, str, expected) -> context label $
|
||||
it ("should be " ++ show expected) $
|
||||
padRight width str `shouldBe` expected)
|
||||
-- label, width, input string, expected
|
||||
[ ( "text shorter", 5, "foo", "foo " )
|
||||
, ( "text longer", 3, "foobar", "foobar" )
|
||||
]
|
||||
|
||||
overlaySpec :: Spec
|
||||
overlaySpec = describe "overlay" $ do
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user