From d14f2ba527075dc587132143c93c278457e8e6ea Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 2 Jan 2020 23:43:44 -0500 Subject: [PATCH 1/3] line numbers on lifetime player report --- src/Mtlstats/Report.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 428fcc7..aabfe6c 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -129,7 +129,7 @@ gameStatsReport width s = let criteria (_, ps) = psPoints ps > 0 - in filteredPlayerReport width "GAME" criteria True playerStats + in filteredPlayerReport width "GAME" criteria True False playerStats ++ [""] ++ gameGoalieReport width goalieStats @@ -146,7 +146,7 @@ yearToDateStatsReport width s = let $ filter goalieIsActive $ db^.dbGoalies - in playerReport width "YEAR TO DATE" True playerStats + in playerReport width "YEAR TO DATE" True False playerStats ++ [""] ++ goalieReport width True goalieStats @@ -161,7 +161,7 @@ lifetimeStatsReport width s = let goalieStats = map (\g -> (g, g^.gLifetime)) $ db^.dbGoalies - in playerReport width "LIFETIME" False playerStats + in playerReport width "LIFETIME" False True playerStats ++ [""] ++ goalieReport width False goalieStats @@ -176,6 +176,7 @@ playerReport :: Int -> String -> Bool + -> Bool -> [(Player, PlayerStats)] -> [String] playerReport width label = @@ -186,9 +187,10 @@ filteredPlayerReport -> String -> ((Player, PlayerStats) -> Bool) -> Bool + -> Bool -> [(Player, PlayerStats)] -> [String] -filteredPlayerReport width label criteria showTotals ps = let +filteredPlayerReport width label criteria showTotals lineNumbers ps = let tStats = foldl addPlayerStats newPlayerStats $ map snd ps criteria' = (&&) <$> criteria <*> \(p, _) -> p^.pNumber /= 0 fps = filter criteria' ps @@ -232,8 +234,13 @@ filteredPlayerReport width label criteria showTotals ps = let then label ++ " TOTALS" else "" + lnOverlay = if lineNumbers + then "" : [right 2 $ show x | x <- [(1 :: Int)..]] + else repeat "" + table = overlayLast olayText - $ map (centre width) + $ map (\(ln, line) -> overlay ln $ centre width line) + $ zip lnOverlay $ complexTable ([right, left] ++ repeat right) $ tHeader : body ++ if showTotals then [separator, totals] From 3a71dc1e62b336c2d0122000592b51d405795472 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 2 Jan 2020 23:50:21 -0500 Subject: [PATCH 2/3] add line numbers to lifetime goalie report --- src/Mtlstats/Report.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index aabfe6c..4894957 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -148,7 +148,7 @@ yearToDateStatsReport width s = let in playerReport width "YEAR TO DATE" True False playerStats ++ [""] - ++ goalieReport width True goalieStats + ++ goalieReport width True False goalieStats lifetimeStatsReport :: Int -> ProgState -> [String] lifetimeStatsReport width s = let @@ -163,7 +163,7 @@ lifetimeStatsReport width s = let in playerReport width "LIFETIME" False True playerStats ++ [""] - ++ goalieReport width False goalieStats + ++ goalieReport width False True goalieStats gameDate :: GameState -> String gameDate gs = fromMaybe "" $ do @@ -251,9 +251,10 @@ filteredPlayerReport width label criteria showTotals lineNumbers ps = let goalieReport :: Int -> Bool + -> Bool -> [(Goalie, GoalieStats)] -> [String] -goalieReport width showTotals goalieData = let +goalieReport width showTotals lineNumbers goalieData = let olayText = if showTotals then "GOALTENDING TOTALS" else "" @@ -292,7 +293,12 @@ goalieReport width showTotals goalieData = let 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 $ complexTable ([right, left] ++ repeat right) $ header : body ++ if showTotals From ba3f8a5a6cd728f21c36c911961e780f9493f62c Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 2 Jan 2020 23:51:36 -0500 Subject: [PATCH 3/3] updated change log --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index c4b542a..f84c758 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ - Return to correct edit menus after editing player stats - Enabled batch editing of player/goalie YTD/lifetime stats - Bugfix: allow user to edit goalie shutouts +- Added line numbers to lifetime player/goalie reports ## 0.9.0 - Bugfix: Display lifetime stats in report, not YTD