#302 Device searching now searches on module serial numbers
This commit is contained in:
6
Changes
6
Changes
@@ -1,3 +1,9 @@
|
||||
2.035000 -
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* #302 Device searching now searches on module serial numbers
|
||||
|
||||
2.034003 - 2017-04-14
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
@@ -283,6 +283,8 @@ The following fields are inspected for a match:
|
||||
|
||||
=item serial
|
||||
|
||||
=item module serials (exact)
|
||||
|
||||
=item location
|
||||
|
||||
=item name
|
||||
@@ -303,6 +305,7 @@ sub search_fuzzy {
|
||||
die "missing param to search_fuzzy\n"
|
||||
unless $q;
|
||||
$q = "\%$q\%" if $q !~ m/\%/;
|
||||
(my $qc = $q) =~ s/\%//g;
|
||||
|
||||
# basic IP check is a string match
|
||||
my $ip_clause = [
|
||||
@@ -311,7 +314,6 @@ sub search_fuzzy {
|
||||
];
|
||||
|
||||
# but also allow prefix search
|
||||
(my $qc = $q) =~ s/\%//g;
|
||||
if (my $ip = NetAddr::IP::Lite->new($qc)) {
|
||||
$ip_clause = [
|
||||
'me.ip' => { '<<=' => $ip->cidr },
|
||||
@@ -327,6 +329,10 @@ sub search_fuzzy {
|
||||
'me.location' => { '-ilike' => $q },
|
||||
'me.name' => { '-ilike' => $q },
|
||||
'me.description' => { '-ilike' => $q },
|
||||
'me.ip' => { '-in' =>
|
||||
$rs->search({ 'modules.serial' => $qc },
|
||||
{ join => 'modules', columns => 'ip' })->as_query()
|
||||
},
|
||||
-or => [
|
||||
'me.dns' => { '-ilike' => $q },
|
||||
'device_ips.dns' => { '-ilike' => $q },
|
||||
|
||||
Reference in New Issue
Block a user