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