Eliminate a database call in device module inventory report when options are used
This commit is contained in:
@@ -60,6 +60,8 @@ hook 'before_template' => sub {
|
||||
};
|
||||
|
||||
get '/ajax/content/report/moduleinventory/data' => require_login sub {
|
||||
send_error( 'Missing parameter', 400 )
|
||||
unless ( param('draw') && param('draw') =~ /\d+/ );
|
||||
|
||||
my $rs = schema('netdisco')->resultset('DeviceModule');
|
||||
$rs = $rs->search( { -bool => 'fru' } ) if param('fruonly');
|
||||
@@ -121,7 +123,9 @@ get '/ajax/content/report/moduleinventory' => require_login sub {
|
||||
}
|
||||
|
||||
@results = $rs->search_by_field( scalar params )->columns(
|
||||
[ qw/ ip description name class type serial hw_ver fw_ver sw_ver model /
|
||||
[ 'ip', 'description', 'name', 'class',
|
||||
'type', 'serial', 'hw_ver', 'fw_ver',
|
||||
'sw_ver', 'model'
|
||||
]
|
||||
)->search(
|
||||
{},
|
||||
@@ -133,7 +137,7 @@ get '/ajax/content/report/moduleinventory' => require_login sub {
|
||||
|
||||
return unless scalar @results;
|
||||
}
|
||||
else {
|
||||
elsif ( !$has_opt ) {
|
||||
@results = $rs->search(
|
||||
{ class => { '!=', undef } },
|
||||
{ select => [ 'class', { count => 'class' } ],
|
||||
|
||||
Reference in New Issue
Block a user