Merge pull request #81 from mtlstats/page-break

add page break to report
This commit is contained in:
Jonathan Lamothe 2020-03-12 22:14:40 -04:00 committed by GitHub
commit 7ca66ad801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

View File

@ -2,6 +2,7 @@
## current
- Ask for database to load on start-up
- Add page break to report file
## 0.14.0
- Fixed a bug that was causing shutouts to not be recorded

View File

@ -206,7 +206,7 @@ reportC = Controller
C.drawString $ unlines $ slice
(s^.scrollOffset)
(fromInteger $ pred rows)
(report (fromInteger $ pred cols) s)
(displayReport (fromInteger $ pred cols) s)
return C.CursorInvisible
, handleController = \e -> do
case e of
@ -215,7 +215,7 @@ reportC = Controller
C.EventSpecialKey C.KeyHome -> modify $ scrollOffset .~ 0
C.EventCharacter '\n' -> do
get >>= liftIO . writeFile reportFilename . unlines . report reportCols
get >>= liftIO . writeFile reportFilename . exportReport reportCols
modify backHome
_ -> return ()

View File

@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Mtlstats.Report (report, gameDate) where
module Mtlstats.Report (displayReport, exportReport, gameDate) where
import Data.List (sortOn)
import qualified Data.Map as M
@ -34,21 +34,37 @@ import Mtlstats.Helpers.Player
import Mtlstats.Types
import Mtlstats.Util
-- | Generates the report
report
-- | Generates the report displayed on screen
displayReport
:: Int
-- ^ The number of columns for the report
-> ProgState
-- ^ The program state
-> [String]
displayReport width s
= report width s
++ [""]
++ lifetimeStatsReport width s
-- | Generates the report to be exported to file
exportReport
:: Int
-- ^ The number of columns in the report
-> ProgState
-- ^ The program state
-> String
exportReport width s
= unlines (report width s)
++ "\f"
++ unlines (lifetimeStatsReport width s)
report :: Int -> ProgState -> [String]
report width s
= standingsReport width s
++ [""]
++ gameStatsReport width s
++ [""]
++ yearToDateStatsReport width s
++ [""]
++ lifetimeStatsReport width s
standingsReport :: Int -> ProgState -> [String]
standingsReport width s = fromMaybe [] $ do