implemented basic logic for generating goalie reports
This commit is contained in:
parent
e7606c8a5e
commit
3b6f77ba21
|
@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
module Mtlstats.Report (report, gameDate) where
|
module Mtlstats.Report (report, gameDate) where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe, mapMaybe)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
|
|
||||||
import Mtlstats.Config
|
import Mtlstats.Config
|
||||||
|
@ -109,21 +109,55 @@ standingsReport width s = fromMaybe [] $ do
|
||||||
Just $ rHeader ++ table
|
Just $ rHeader ++ table
|
||||||
|
|
||||||
gameStatsReport :: Int -> ProgState -> [String]
|
gameStatsReport :: Int -> ProgState -> [String]
|
||||||
gameStatsReport width s = playerReport width "GAME" $
|
gameStatsReport width s = let
|
||||||
fromMaybe [] $ mapM
|
gs = s^.progMode.gameStateL
|
||||||
|
db = s^.database
|
||||||
|
|
||||||
|
playerStats = mapMaybe
|
||||||
(\(pid, stats) -> do
|
(\(pid, stats) -> do
|
||||||
p <- nth pid $ s^.database.dbPlayers
|
p <- nth pid $ db^.dbPlayers
|
||||||
Just (p, stats))
|
Just (p, stats))
|
||||||
(M.toList $ s^.progMode.gameStateL.gamePlayerStats)
|
(M.toList $ gs^.gamePlayerStats)
|
||||||
|
|
||||||
|
goalieStats = mapMaybe
|
||||||
|
(\(gid, stats) -> do
|
||||||
|
g <- nth gid $ db^.dbGoalies
|
||||||
|
Just (g, stats))
|
||||||
|
(M.toList $ gs^.gameGoalieStats)
|
||||||
|
|
||||||
|
in playerReport width "GAME" playerStats
|
||||||
|
++ [""]
|
||||||
|
++ goalieReport width goalieStats
|
||||||
|
|
||||||
yearToDateStatsReport :: Int -> ProgState -> [String]
|
yearToDateStatsReport :: Int -> ProgState -> [String]
|
||||||
yearToDateStatsReport width s = playerReport width "YEAR TO DATE" $
|
yearToDateStatsReport width s = let
|
||||||
map (\p -> (p, p^.pYtd)) $
|
db = s^.database
|
||||||
filter playerIsActive $ s^.database.dbPlayers
|
|
||||||
|
playerStats = map (\p -> (p, p^.pYtd))
|
||||||
|
$ filter playerIsActive
|
||||||
|
$ db^.dbPlayers
|
||||||
|
|
||||||
|
goalieStats = map (\g -> (g, g^.gYtd))
|
||||||
|
$ filter goalieIsActive
|
||||||
|
$ db^.dbGoalies
|
||||||
|
|
||||||
|
in playerReport width "YEAR TO DATE" playerStats
|
||||||
|
++ [""]
|
||||||
|
++ goalieReport width goalieStats
|
||||||
|
|
||||||
lifetimeStatsReport :: Int -> ProgState -> [String]
|
lifetimeStatsReport :: Int -> ProgState -> [String]
|
||||||
lifetimeStatsReport width s = playerReport width "LIFETIME" $
|
lifetimeStatsReport width s = let
|
||||||
map (\p -> (p, p^.pLifetime)) $ s^.database.dbPlayers
|
db = s^.database
|
||||||
|
|
||||||
|
playerStats = map (\p -> (p, p^.pYtd))
|
||||||
|
$ db^.dbPlayers
|
||||||
|
|
||||||
|
goalieStats = map (\g -> (g, g^.gYtd))
|
||||||
|
$ db^.dbGoalies
|
||||||
|
|
||||||
|
in playerReport width "LIFETIME" playerStats
|
||||||
|
++ [""]
|
||||||
|
++ goalieReport width goalieStats
|
||||||
|
|
||||||
gameDate :: GameState -> String
|
gameDate :: GameState -> String
|
||||||
gameDate gs = fromMaybe "" $ do
|
gameDate gs = fromMaybe "" $ do
|
||||||
|
@ -177,3 +211,6 @@ playerReport width label ps = let
|
||||||
$ tHeader : body ++ [separator, totals]
|
$ tHeader : body ++ [separator, totals]
|
||||||
|
|
||||||
in rHeader ++ table
|
in rHeader ++ table
|
||||||
|
|
||||||
|
goalieReport :: Int -> [(Goalie, GoalieStats)] -> [String]
|
||||||
|
goalieReport = undefined
|
||||||
|
|
|
@ -170,7 +170,8 @@ module Mtlstats.Types (
|
||||||
-- ** Goalie Helpers
|
-- ** Goalie Helpers
|
||||||
goalieSearch,
|
goalieSearch,
|
||||||
goalieSearchExact,
|
goalieSearchExact,
|
||||||
goalieSummary
|
goalieSummary,
|
||||||
|
goalieIsActive
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (StateT)
|
import Control.Monad.Trans.State (StateT)
|
||||||
|
@ -984,3 +985,8 @@ goalieSearchExact sStr goalies = let
|
||||||
-- | Provides a description string for a 'Goalie'
|
-- | Provides a description string for a 'Goalie'
|
||||||
goalieSummary :: Goalie -> String
|
goalieSummary :: Goalie -> String
|
||||||
goalieSummary g = g^.gName ++ " (" ++ show (g^.gNumber) ++ ")"
|
goalieSummary g = g^.gName ++ " (" ++ show (g^.gNumber) ++ ")"
|
||||||
|
|
||||||
|
-- | Determines whether or not a goalie has been active in the current
|
||||||
|
-- season
|
||||||
|
goalieIsActive :: Goalie -> Bool
|
||||||
|
goalieIsActive = undefined
|
||||||
|
|
Loading…
Reference in New Issue
Block a user