From 7a8bcb094e4d48dd0d900d275ca5ce781ddb42ba Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 2 Mar 2019 22:23:39 +0000 Subject: [PATCH] #521 Search Node Date Range not working --- .../Netdisco/Web/Plugin/Report/IpInventory.pm | 2 +- lib/App/Netdisco/Web/Plugin/Search/Node.pm | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm index 437462ae..0fc809f0 100644 --- a/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm +++ b/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm @@ -115,7 +115,7 @@ get '/ajax/content/report/ipinventory' => require_login sub { )->as_query; my $rs; - if ( $start && $end ) { + if ( $start and $end ) { $start = $start . ' 00:00:00'; $end = $end . ' 23:59:59'; diff --git a/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 45394e2c..090802a5 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -27,35 +27,51 @@ ajax '/ajax/content/search/node' => require_login sub { my @active = (param('archived') ? () : (-bool => 'active')); my (@times, @wifitimes, @porttimes); - if ($start and $end) { + if ( $start and $end ) { $start = $start . ' 00:00:00'; $end = $end . ' 23:59:59'; + if ($agenot) { @times = (-or => [ - time_first => [ { '<', $start }, undef ], - time_last => { '>', $end }, + time_first => [ undef ], + time_last => [ { '<', $start }, { '>', $end } ] ]); @wifitimes = (-or => [ - time_last => { '<', $start }, - time_last => { '>', $end }, + time_first => [ undef ], + time_last => [ { '<', $start }, { '>', $end } ] ]); @porttimes = (-or => [ - creation => { '<', $start }, - creation => { '>', $end }, + creation => [ undef ], + creation => [ { '<', $start }, { '>', $end } ] ]); } else { - @times = (-and => [ - time_first => { '>=', $start }, - time_last => { '<=', $end }, + @times = (-or => [ + -and => [ + time_first => undef, + time_last => undef, + ], + -and => [ + time_last => { '>=', $start }, + time_last => { '<=', $end }, + ], ]); - @wifitimes = (-and => [ - time_last => { '>=', $start }, - time_last => { '<=', $end }, + @wifitimes = (-or => [ + -and => [ + time_first => undef, + time_last => undef, + ], + -and => [ + time_last => { '>=', $start }, + time_last => { '<=', $end }, + ], ]); - @porttimes = (-and => [ - creation => { '>=', $start }, - creation => { '<=', $end }, + @porttimes = (-or => [ + creation => undef, + -and => [ + creation => { '>=', $start }, + creation => { '<=', $end }, + ], ]); } }