photo-stats

statistics processor for the terminal
git clone https://git.clttr.info/photo-stats.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 01386ffa97ddb8557c68e714bb114ee521656ba3
parent bbbfdebe0e9351f7033f2f8f2b68caf2d92ec76c
Author: René Wagner <rwagner@rw-net.de>
Date:   Sat, 12 Sep 2020 16:32:15 +0200

refactoring

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

diff --git a/phosta.pl b/phosta.pl @@ -294,17 +294,6 @@ sub query my $headers = $stmt->{NAME}; $dbh->disconnect(); - result_to_stdout($headers, $rows); -} - -sub result_to_stdout -{ - my ( $headers, $rows ) = @_; - - my $currentlines=0; - my $skippedlines=0; - my $tb = Text::SimpleTable::AutoWidth->new(); - push @$headers, 'percent'; my $sum = 0; foreach (@$rows) @@ -317,6 +306,18 @@ sub result_to_stdout push @$_, $perc; } + if (@$headers == 3) { result_to_graph($headers, $rows, $sum); } + else { result_to_table($headers, $rows, $sum); } +} + +sub result_to_table +{ + my ( $headers, $rows, $sum ) = @_; + + my $currentlines=0; + my $skippedlines=0; + my $tb = Text::SimpleTable::AutoWidth->new(); + $tb->captions($headers); foreach (@$rows) {