From b8433373b53cc917af37c135b6a970b8f497d014 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 15 Aug 2020 17:49:11 -0400 Subject: [PATCH] Rough in Pre and Post SQL Conditions in execute. Rough in ExistsInFileSystem support. Needs more work. --- scripts/ZoneMinder/lib/ZoneMinder/Filter.pm | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index c0e05226e..d18df337c 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -82,8 +82,8 @@ sub Execute { my $self = $_[0]; my $sql = $self->Sql(undef); - if ( @{$$self{PreConditions}} ) { - foreach my $term ( @{$$self{PreConditions}} ) { + if ( @{$$self{PreSQLConditions}} ) { + foreach my $term ( @{$$self{PreSQLConditions}} ) { if ( $$term{attr} eq 'DiskPercent' ) { } } @@ -116,10 +116,22 @@ sub Execute { } $sth->finish(); Debug('Loaded ' . @results . ' events for filter '.$$self{Name}.' using query ('.$sql.')"'); - if ( $self->{HasNonSqlConditions} ) { - } + if ( $self->{PostSQLConditions} ) { + my @filtered_events; + foreach my $term ( @{$$self{PostSQLConditions}} ) { + if ( $$term{attr} eq 'ExistsInFileSystem' ) { + foreach my $row ( @results ) { + my $event = new ZoneMinder::Event($row); + if ( -e $event->Path() ) { + push @filtered_events, $row; + } + } + } + } # end foreach term + @results = @filtered_events; + } # end if has PostSQLConditions return @results; -} +} # end sub Execute sub Sql { my $self = shift;