From 9de4f9c3b90274add6ba8dffd596a36c51209ece Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Fri, 31 May 2024 17:35:46 +0200
Subject: [PATCH] - added full filetypes support - improved
 print_humanreadable_report() output for a beautiful asciidoc output

---
 lib/SLUB/LZA/TA/Command/report.pm | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/lib/SLUB/LZA/TA/Command/report.pm b/lib/SLUB/LZA/TA/Command/report.pm
index 3a5a190..eec1ced 100644
--- a/lib/SLUB/LZA/TA/Command/report.pm
+++ b/lib/SLUB/LZA/TA/Command/report.pm
@@ -170,7 +170,7 @@ sub validate_args {
     my $to_epoch = Date_to_Time($to_year, $to_month, $to_day, 0, 0, 0);
     $self->usage_error('--date-to should have a date newer than --date-from')if ($from_epoch > $to_epoch);
     printf STDERR "reporting for period %04u-%02u-%02u … %04u-%02u-%02u\n", $from_year, $from_month, $from_day, $to_year, $to_month, $to_day;
-    say STDERR "HINT: the option '--with-ldp' results in lot of processing time and network traffic, use it with care!" if (exists $opt->{with_ldp});
+    say STDERR "HINT: the option '--with-ldp'       results in lot of processing time and network traffic, use it with care!" if (exists $opt->{with_ldp});
     say STDERR "HINT: the option '--with-filetypes' results in lot of processing time and network traffic, use it with care!" if (exists $opt->{with_filetypes});
     $opt->{creationdate_epochs}->{from} = $from_epoch;
     $opt->{creationdate_epochs}->{to} = $to_epoch;
@@ -561,15 +561,27 @@ sub print_humanreadable_report ($results) {
 
 = Report from $results->{from} to $results->{to}
 RPTHEADER
+    say "== Complete archive\n";
     foreach my $flavour (sort keys %{$results->{flavour}}) {
-
-        say "== $flavour\n";
-        foreach my $aipstate (AIPSTATE) {
-            printf "*  %10s:\n", $aipstate;
+        say "=== $flavour\n";
+        foreach my $aip_state (AIPSTATE) {
+            printf "*  %10s:\n", $aip_state;
+            #use Data::Printer; p($results->{flavour}->{$flavour}->{$aip_state}); #die;
             foreach my $set (SETS) {
-                printf "**    %15s: %10u\n",
-                    $set,
-                    $results->{flavour}->{$flavour}->{$aipstate}->{$set}->{""};
+                foreach my $filter (sort keys %{$results->{flavour}->{$flavour}->{$aip_state}->{$set}}) {
+#say "FILTER='$filter'";
+                    if ($filter eq "") {
+                        printf "**    %15s: %10u\n",
+                            "$set",
+                            $results->{flavour}->{$flavour}->{$aip_state}->{$set}->{""}
+                        ;
+                    } else {
+                        printf "***    %25s: %10u\n",
+                            $filter,
+                            $results->{flavour}->{$flavour}->{$aip_state}->{$set}->{$filter}
+                        ;
+                    }
+                }
             }
             say;
         }
-- 
GitLab