photo-stats

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/photo-stats.git
Log | Files | Refs | README | LICENSE

commit 4ae7bef994bf4bab7e5668948e6449b89fba914c
parent 01386ffa97ddb8557c68e714bb114ee521656ba3
Author: René Wagner <rwagner@rw-net.de>
Date:   Sat, 12 Sep 2020 18:55:33 +0200

further refactor for introducing graphs

Diffstat:
Mphosta.pl | 49+++++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 12 deletions(-)

diff --git a/phosta.pl b/phosta.pl @@ -306,19 +306,20 @@ sub query push @$_, $perc; } - if (@$headers == 3) { result_to_graph($headers, $rows, $sum); } - else { result_to_table($headers, $rows, $sum); } + my ($limited_rows, $skippedlines) = limit_results($rows); + + print_filterinfo(scalar @$limited_rows, $skippedlines, $sum); + if (@$headers == 3) { result_to_graph($headers, $limited_rows, $sum); } + else { result_to_table($headers, $limited_rows, $sum); } } -sub result_to_table +sub limit_results { - my ( $headers, $rows, $sum ) = @_; + my ( $rows ) = @_; + my $skippedlines = 0; + my $currentlines = 0; + my @limited_rows; - my $currentlines=0; - my $skippedlines=0; - my $tb = Text::SimpleTable::AutoWidth->new(); - - $tb->captions($headers); foreach (@$rows) { if (!defined($opt_n) || ($currentlines < $opt_n)) @@ -336,15 +337,20 @@ sub result_to_table next; } } - $tb->row(@$_); + push @limited_rows, $_; $currentlines++; } else { $skippedlines++; } - } - + } + return (\@limited_rows, $skippedlines); +} + +sub print_filterinfo +{ + my ($currentlines, $skippedlines, $sum) = @_; if (defined($opt_f) || defined($opt_t)) { say 'Applied filters:'; @@ -368,7 +374,26 @@ sub result_to_table } say 'A total of '. color('bold'). "$sum images". color('reset') .' matched your criteria.'; say ''; +} + +sub result_to_table +{ + my ( $headers, $rows, $sum ) = @_; + +} +sub result_to_table +{ + my ( $headers, $rows, $sum, $skippedlines ) = @_; + + my $tb = Text::SimpleTable::AutoWidth->new(); + + $tb->captions($headers); + foreach (@$rows) + { + $tb->row(@$_); + } + if (scalar @$rows) { say $tb->draw; } }