diff options
author | Andinus <andinus@nand.sh> | 2021-09-01 16:49:42 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-09-01 16:49:42 +0530 |
commit | e472da737b53e742d02e5db96fdd260577542d74 (patch) | |
tree | b2c47b6f9cfc396482bcbdefb51d8ea1af50657f /lib/Taurus | |
parent | b827aa3d73d76b608d5e9b7051f1dad778a95c8e (diff) | |
download | taurus-master.tar.gz |
Diffstat (limited to 'lib/Taurus')
-rw-r--r-- | lib/Taurus/CLI.rakumod | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/Taurus/CLI.rakumod b/lib/Taurus/CLI.rakumod index ba98381..ecd245c 100644 --- a/lib/Taurus/CLI.rakumod +++ b/lib/Taurus/CLI.rakumod @@ -15,8 +15,6 @@ multi sub MAIN ( ) is export { my @logs; my Str %contacts{Str}; - my Str @month-name = <Month January February March April May June - July August September October November December>; my Instant $timed = now; my Promise $initial = start { @@ -86,16 +84,7 @@ multi sub MAIN ( print-basic-stats($p1, @logs) with %meta<all>; with %meta<year> -> $year { - $p1.put: "Year: " ~ $year; - $p1.put: ""; - with @logs.grep(*.[3].year eqv $year) { - print-basic-stats($p1, $_); - $p1.put: ""; - for .map(*.[3].month).unique.sort -> $month { - $p1.put: "%-*s %s".sprintf($fmt, @month-name[$month] ~ ":", - seconds-to-str(.grep(*.[3].month eqv $month).map(*.[4]).sum)); - } - } + print-yearly-record($p1, @logs, $year); } with %meta<number> -> $num { @@ -103,6 +92,10 @@ multi sub MAIN ( $p1.put: "Number: " ~ $num; $p1.put: ""; print-basic-stats($p1, @logs.grep(*.[1] eqv $num)); + + for @logs.map(*.[3].year).unique -> $year { + print-yearly-record($p1, @logs, $year); + } } $p1.select-first; } @@ -111,6 +104,20 @@ multi sub MAIN ( ui.shutdown; } +sub print-yearly-record($p1, @logs, $year) { + constant $fmt = 16; + my Str @month-name = <Month January February March April May June + July August September October November December>; + $p1.put: ""; + $p1.put: "Year: " ~ $year; + with @logs.grep(*.[3].year eqv $year).cache { + for .map(*.[3].month).unique.sort -> $month { + $p1.put: " %-*s %s".sprintf($fmt, @month-name[$month] ~ ":", + seconds-to-str(.grep(*.[3].month eqv $month).map(*.[4]).sum)); + } + } +} + sub print-basic-stats($p1, @logs) { constant $fmt = 16; with @logs { |