Eliminate an necessary database call in Module Inventory, Port SSID, and NetBIOS reports

This commit is contained in:
Eric A. Miller
2014-02-16 23:27:26 -05:00
parent 66c0a9d4fa
commit d1aa325bc7
9 changed files with 20 additions and 29 deletions

View File

@@ -96,12 +96,14 @@ get '/ajax/content/report/moduleinventory' => require_login sub {
return unless $rs->has_rows;
if ( request->is_ajax ) {
template 'ajax/report/moduleinventory.tt', { results => $rs, },
template 'ajax/report/moduleinventory.tt',
{ results => $rs, opt => $has_opt },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/moduleinventory_csv.tt', { results => $rs, },
template 'ajax/report/moduleinventory_csv.tt',
{ results => $rs, opt => $has_opt },
{ layout => undef };
}
};

View File

@@ -42,11 +42,10 @@ get '/ajax/content/report/netbios' => require_login sub {
if ( defined $domain ) {
$domain = '' if $domain eq 'blank';
$rs = $rs->search( { domain => $domain } )->order_by(
[ { -asc => 'domain' },
{ -desc => 'time_last' }
]
)->hri;
$rs
= $rs->search( { domain => $domain } )
->order_by( [ { -asc => 'domain' }, { -desc => 'time_last' } ] )
->hri;
}
else {
$rs = $rs->search(
@@ -62,12 +61,13 @@ get '/ajax/content/report/netbios' => require_login sub {
return unless $rs->has_rows;
if ( request->is_ajax ) {
template 'ajax/report/netbios.tt', { results => $rs, },
template 'ajax/report/netbios.tt', { results => $rs, opt => $domain },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/netbios_csv.tt', { results => $rs, },
template 'ajax/report/netbios_csv.tt',
{ results => $rs, opt => $domain },
{ layout => undef };
}
};

View File

@@ -57,12 +57,13 @@ get '/ajax/content/report/portssid' => require_login sub {
return unless $rs->has_rows;
if ( request->is_ajax ) {
template 'ajax/report/portssid.tt', { results => $rs, },
template 'ajax/report/portssid.tt', { results => $rs, opt => $ssid },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/portssid_csv.tt', { results => $rs, },
template 'ajax/report/portssid_csv.tt',
{ results => $rs, opt => $ssid },
{ layout => undef };
}
};

View File

@@ -1,6 +1,5 @@
[% USE Number.Format %]
[% IF results.first.ip %]
[% row = results.reset %]
[% IF opt %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
@@ -62,7 +61,6 @@
</tbody>
</table>
[% ELSE %]
[% row = results.reset %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>

View File

@@ -1,6 +1,5 @@
[% USE CSV -%]
[% IF results.first.ip %]
[% row = results.reset %]
[% IF opt %]
[% CSV.dump(['Device' 'Description' 'Name' 'Class' 'Type' 'Model' 'Serial' 'HW Version' 'SW Version' 'FW Version']) %]
[% WHILE (row = results.next) %]
@@ -13,7 +12,6 @@
[% END %]
[% ELSE %]
[% row = results.reset %]
[% CSV.dump(['Class' 'Count']) %]
[% WHILE (row = results.next) %]

View File

@@ -1,7 +1,6 @@
[% USE date(format = '%Y-%m-%d %H:%M') %]
[% USE Number.Format %]
[% IF results.first.mac %]
[% row = results.reset %]
[% IF opt %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
@@ -27,7 +26,6 @@
</tbody>
</table>
[% ELSE %]
[% row = results.reset %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>

View File

@@ -1,7 +1,6 @@
[% USE CSV -%]
[% USE date(format = '%Y-%m-%d %H:%M') %]
[% IF results.first.ip %]
[% row = results.reset %]
[% IF opt %]
[% CSV.dump(['Domain' 'Node' 'Name' 'User' 'First Seen' 'Last Seen']) %]
[% WHILE (row = results.next) %]
@@ -14,7 +13,6 @@
[% END %]
[% ELSE %]
[% row = results.reset %]
[% CSV.dump(['Domain' 'Count']) %]
[% WHILE (row = results.next) %]

View File

@@ -1,6 +1,5 @@
[% USE Number.Format %]
[% IF results.first.device.ip %]
[% row = results.reset %]
[% IF opt %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
@@ -28,7 +27,6 @@
</tbody>
</table>
[% ELSE %]
[% row = results.reset %]
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>

View File

@@ -1,6 +1,5 @@
[% USE CSV -%]
[% IF results.first.ip %]
[% row = results.reset %]
[% IF opt %]
[% CSV.dump(['Device' 'Port' 'Name' 'Broadcast' 'Model' 'SSID' 'Vendor']) %]
[% WHILE (row = results.next) %]
@@ -14,7 +13,6 @@
[% END %]
[% ELSE %]
[% row = results.reset %]
[% CSV.dump(['SSID' 'Count']) %]
[% WHILE (row = results.next) %]