From c64b68c99ccbb00800faf93f25fcb425992f6ec4 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 13 Feb 2012 23:13:19 +0000 Subject: [PATCH] remove an unecessary count() --- Netdisco/lib/Netdisco/Web/Device.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Netdisco/lib/Netdisco/Web/Device.pm b/Netdisco/lib/Netdisco/Web/Device.pm index 4d85b8a1..08ad879c 100644 --- a/Netdisco/lib/Netdisco/Web/Device.pm +++ b/Netdisco/lib/Netdisco/Web/Device.pm @@ -83,20 +83,18 @@ ajax '/ajax/content/device/ports' => sub { if ($q) { if ($q =~ m/^\d+$/) { $set = $set->search_by_vlan({vlan => $q}); + return unless $set->count; } else { - my $c = schema('netdisco')->resultset('DevicePort') - ->search_by_ip({ip => $ip}) - ->search_by_port({port => $q}); - if ($c->count) { + if ($set->search_by_port({port => $q})->count) { $set = $set->search_by_port({port => $q}); } else { $set = $set->search_by_name({name => $q}); + return unless $set->count; } } } - return unless $set->count; # retrieve related data for additonal table columns, if asked for $set = $set->search_rs({}, {prefetch => {nodes => 'ips'}}) @@ -106,10 +104,12 @@ ajax '/ajax/content/device/ports' => sub { # if active or not, control the join to Node table if (param('n_archived')) { - $set = $set->search_rs({-or => [{'nodes.active' => 1}, {'nodes.active' => 0}]}); + $set = $set->search_rs({ + -or => [{-bool => 'nodes.active'}, {-not_bool => 'nodes.active'}] + }); } else { - $set = $set->search_rs({'nodes.active' => 1}); + $set = $set->search_rs({-bool => 'nodes.active'}); } # sort, and filter by free ports