Eliminate a database call in device module inventory report when options are used

This commit is contained in:
Eric A. Miller
2014-06-19 19:22:18 -04:00
parent eacd19f390
commit 6389783174

View File

@@ -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' } ],