Skip to content

Commit

Permalink
Make compatible with base-4.14, empty timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Apr 25, 2021
1 parent 92d5597 commit ef61aed
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.10
==========
* Compatibility with base-4.14

0.1.9
==========
* Introduced passing the list of report durations into the script type output.
Expand Down
4 changes: 2 additions & 2 deletions orgstat.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: orgstat
version: 0.1.9
version: 0.1.10
synopsis: Statistics visualizer for org-mode
license: GPL-3
license-file: LICENSE
Expand Down Expand Up @@ -33,7 +33,7 @@ library
build-depends: aeson >= 0.11.2.0
, attoparsec
, ansi-terminal
, base >=4.13 && <4.14
, base >=4.13 && <4.15
, boxes >= 0.1.4
, bytestring
, colour >= 2.3.3
Expand Down
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
with import <nixpkgs> { };
haskell.lib.buildStackProject {
#ghc = haskell.packages.ghc8102.ghc;
ghc = haskell.packages.ghc882.ghc;
name = "orgstat";
# firefox for xdg-open
Expand Down
20 changes: 18 additions & 2 deletions src/OrgStat/Outputs/Timeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module OrgStat.Outputs.Timeline

import Data.Colour.CIE (luminance)
import Data.List (lookup, nub)
import qualified Data.List as L
import qualified Data.Text as T
import Data.Time (Day, DiffTime, LocalTime(..), defaultTimeLocale, formatTime, timeOfDayToTime)
import Diagrams.Backend.SVG (B)
Expand Down Expand Up @@ -214,16 +215,31 @@ taskList params labels fit = D.vsep 5 $ map oneTask $ reverse $ sortOn snd label
where
(hours, minutes) = diffTimeMinutes time `divMod` 60

emptyReport :: D.Diagram B
emptyReport =
mconcat
[ D.strutY 20
, D.strutX 40
, D.alignedText 0.5 0 "empty"
& D.font "DejaVu Sans"
& D.fontSize 8
]

timelineReport :: TimelineParams -> Org -> TimelineOutput
timelineReport params org = TimelineOutput pic
timelineReport params org =
if (null $ concat $ org ^.. traverseTree . orgClocks)
then
TimelineOutput $ D.vsep 30 [emptyReport]

else TimelineOutput pic
where
lookupDef :: Eq a => b -> a -> [(a, b)] -> b
lookupDef d a xs = fromMaybe d $ lookup a xs

-- These two should be taken from the Org itself (min/max).
(from,to) =
let c = concat $ org ^.. traverseTree . orgClocks
in (minimum (map cFrom c), maximum (map cTo c))
in (L.minimum (map cFrom c), L.maximum (map cTo c))

-- period to show. Right border is -1min, we assume it's non-inclusive
daysToShow = [localDay from ..
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-15.2
#resolver: nightly-2020-12-14

nix:
shell-file: shell.nix
Expand Down

0 comments on commit ef61aed

Please sign in to comment.