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 0bc03176406d6671148ff239e3dbc60ea973bd18
parent 1be87c2edfd66a393d311e5ca2ad392d337276ff
Author: René Wagner <rwagner@rw-net.de>
Date:   Fri, 28 Aug 2020 21:19:57 +0200

finish filter output

Diffstat:
Mphosta.pl | 34+++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/phosta.pl b/phosta.pl @@ -84,7 +84,7 @@ sub validate $opt_E =~ /^([a-z]{2,4}){1,}(\,[a-z]{2,4}){0,}$/ or return 0; - !defined($opt_f) || $opt_f =~ /^[\w]{2,}(!){0,1}=[\w]{1,}(,[\w]{2,}(!){0,1}=[\w]{1,}){0,}$/ or return 0; + !defined($opt_f) || $opt_f =~ /^[\w\-]{2,}(!){0,1}=[\w]{1,}(,[\w]{2,}(!){0,1}=[\w\-]{1,}){0,}$/ or return 0; return 1; } @@ -164,6 +164,22 @@ sub get_timerange return ($from, $to); } +sub get_filters +{ + if (defined($opt_f)) + { + my @returnarray; + my (@filters) = split /\,/, $opt_f; + foreach (@filters) + { + my @line = split /(!{0,1}=)/, $_; + push @returnarray, \@line; + } + return @returnarray; + } + return undef; +} + sub get_sql { my $fieldlist = ''; @@ -214,14 +230,10 @@ sub get_sql !defined($to) or push @wherearray, "datetimeoriginal <= '$to'"; } - if (defined($opt_f)) + + foreach (get_filters()) { - my (@filters) = split /\,/, $opt_f; - foreach (@filters) - { - my ( $sub1, $sub2, $sub3 ) = split /(!){0,1}=/, $_; - push @wherearray, $sub1 . ($_ =~ /!/ ? ' NOT ' : '') . " LIKE '%$sub3%'"; - } + push @wherearray, @{$_}[0] . (@{$_}[1] =~ /!/ ? ' NOT' : '') . " LIKE '%@{$_}[2]%'"; } my $wherelist = ''; @@ -297,6 +309,10 @@ sub result_to_stdout if (defined($from) && !defined($to)) { say ' - images taken since '. color('bold'). $from . color('reset'); } if (defined($to) && !defined($from)) { say ' - images taken till '. color('bold'). $to . color('reset'); } } + foreach (get_filters()) + { + say ' - ' .color('italic') . @{$_}[0] .color('reset') . (@{$_}[1] =~ /!/ ? ' NOT' : '') . ' LIKE ' .color('bold') .@{$_}[2]. color('reset');; + } say ''; } @@ -306,7 +322,7 @@ sub result_to_stdout } say 'A total of '. color('bold'). "$sum images". color('reset') .' matched your criteria.'; say ''; - say $tb->draw; + if (scalar @$rows) { say $tb->draw; } } sub main::VERSION_MESSAGE()