From c21cce5a669e5613d3c9e1bf404a086893b5bef5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 12 Feb 2023 13:56:35 +0200 Subject: add ideas --- src/guprecords.raku | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/guprecords.raku b/src/guprecords.raku index 3d0ccd1..19718b5 100644 --- a/src/guprecords.raku +++ b/src/guprecords.raku @@ -28,7 +28,7 @@ class Aggregate { method lifespan { self.downtime + $.uptime } method Str returns Str { - my Str $active = self!is-active ?? '* ' !! ' '; + my Str $active = self!is-active ?? '*' !! ' '; return "$active {$!name}\t{duration($!uptime)} {$!uptime}" } @@ -73,11 +73,17 @@ class Aggregator { } } -role Sorting { +class Reporter { has Hash %.aggregates is required; has Cat $.cat is required; has SubCat $.sub-cat is required; + method report { + for self.sort-by($!sub-cat) -> $what { + $what.Str.say; + } + } + multi method sort-by('uptime') { self.sort-by: *.uptime } multi method sort-by('downtime') { self.sort-by: *.downtime } multi method sort-by('lifespan') { self.sort-by: *.lifespan } @@ -88,14 +94,6 @@ role Sorting { } } -class Reporter does Sorting { - method report { - for self.sort-by($!sub-cat) -> $what { - $what.Str.say; - } - } -} - sub MAIN( Str :$stats-dir is required, #= The uptimed raw record input dir. Cat :$cat = 'hostname'; #= Category, one of hostname, os os-major and uname. -- cgit v1.2.3