Skip to content
Snippets Groups Projects
Commit 9d9e1f0c authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- add prepare_for_table() to allow printing in table format like RSV or CSV

parent 3b2aea51
No related branches found
No related tags found
No related merge requests found
......@@ -211,10 +211,39 @@ sub execute {
$results{ldp_project}->{$ldp_project}->{flavour}->{files}->{$aip_state} = $res->{aggregations}->{total_file_count}->{value};
}
}
print_humanreadable_report(\%results);
#print_humanreadable_report(\%results);
my ($headers, $table) = prepare_for_table(\%results, \@ldp_projects);
SLUB::LZA::TA::Output::CSV::print_results($headers, $table);
say STDERR "report is already sent to STDOUT.";
}
sub prepare_for_table($results, $ldp_projects) {
my @table;
foreach my $aip_state (qw(new updated total)) {
foreach my $flavour (keys %{$results->{flavour}}) { # count size file
foreach my $ldp_funder (qw(saxony misc none full)) {
my $line;
$line->{_set} = $ldp_funder;
$line->{_subset} = "";
$line->{flavour} = $flavour;
$line->{aip_state} = $aip_state;
$line->{value} = $results->{flavour}->{$flavour}->{$aip_state}->{$ldp_funder};
push @table, $line;
}
foreach my $ldp_project (@{ $ldp_projects }) {
my $line;
$line->{_set} = "LDP";
$line->{_subset} = $ldp_project;
$line->{flavour} = $flavour;
$line->{aip_state} = $aip_state;
$line->{value} = $results->{ldp_project}->{$ldp_project}->{flavour}->{$flavour}->{$aip_state};
push @table, $line;
}
}
}
my @headers = sort keys %{ $table[0] };
return \@headers, \@table;
}
sub print_humanreadable_report ($result) {
say <<"RPTHEADER";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment