remove unecessary distinct from device searches, and fix bug in by_field

This commit is contained in:
Oliver Gorwits
2012-02-19 15:59:03 +00:00
parent b4dc437d07
commit dbb880a142

View File

@@ -123,7 +123,7 @@ sub search_by_field {
# this is a bit of an inelegant trick to catch junk data entry, # this is a bit of an inelegant trick to catch junk data entry,
# whilst avoiding returning *all* entries in the table # whilst avoiding returning *all* entries in the table
if (exists $p->{ip} and defined $p->{ip} and 'NetAddr::IP::Lite' ne ref $p->{ip}) { if (length $p->{ip} and 'NetAddr::IP::Lite' ne ref $p->{ip}) {
$p->{ip} = ( NetAddr::IP::Lite->new($p->{ip}) $p->{ip} = ( NetAddr::IP::Lite->new($p->{ip})
|| NetAddr::IP::Lite->new('255.255.255.255') ); || NetAddr::IP::Lite->new('255.255.255.255') );
} }
@@ -161,8 +161,7 @@ sub search_by_field {
}, },
{ {
order_by => [qw/ me.dns me.ip /], order_by => [qw/ me.dns me.ip /],
join => 'device_ips', (($p->{dns} or $p->{ip}) ? (join => 'device_ips') : ()),
distinct => 1,
} }
); );
} }
@@ -234,7 +233,6 @@ sub search_fuzzy {
{ {
order_by => [qw/ me.dns me.ip /], order_by => [qw/ me.dns me.ip /],
join => 'device_ips', join => 'device_ips',
distinct => 1,
} }
); );
} }