Try NodeIp OUI company name search if no node results found

This commit is contained in:
Oliver Gorwits
2013-09-25 18:01:43 +01:00
parent cb88267717
commit b1bce3c535
3 changed files with 36 additions and 0 deletions

View File

@@ -59,6 +59,18 @@ ajax '/ajax/content/search/node' => require_login sub {
}
$set = schema('netdisco')->resultset('NodeIp')
->search_by_dns({dns => $node, @active});
# if the user selects Vendor search opt, then
# we'll try the OUI company name as a fallback
if (not $set->count and param('show_vendor')) {
$node = param('q');
$set = schema('netdisco')->resultset('NodeIp')
->with_times
->search(
{'oui.company' => { -ilike => "\%$node\%"}},
{'prefetch' => 'oui'},
);
}
}
return unless $set and $set->count;
$set = $set->search_rs({}, { order_by => 'me.mac' });