stats: don't break on an empty file
This commit is contained in:
parent
fe12bd9c94
commit
7f8a352c0c
@ -72,7 +72,9 @@ showStats _ _ l today =
|
|||||||
tnum7 = length $ filter withinlast7 ts
|
tnum7 = length $ filter withinlast7 ts
|
||||||
withinlast7 t = d >= addDays (-7) today && (d<=today) where d = tdate t
|
withinlast7 t = d >= addDays (-7) today && (d<=today) where d = tdate t
|
||||||
txnrate7 = fromIntegral tnum7 / 7 :: Double
|
txnrate7 = fromIntegral tnum7 / 7 :: Double
|
||||||
acctnum = length $ accounts l
|
acctnum = length as
|
||||||
acctdepth = maximum $ map (accountNameLevel.aname) $ accounts l
|
acctdepth | null as = 0
|
||||||
|
| otherwise = maximum $ map (accountNameLevel.aname) as
|
||||||
|
as = accounts l
|
||||||
cs = Map.elems $ commodities l
|
cs = Map.elems $ commodities l
|
||||||
|
|
||||||
|
|||||||
3
tests/stats-empty-file.test
Normal file
3
tests/stats-empty-file.test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bin/hledger -f- stats
|
||||||
|
<<<
|
||||||
|
>>> /Accounts.* 0 \(depth 0\)/
|
||||||
Loading…
Reference in New Issue
Block a user