Eliminate one db call in IP subnet utilization report. Limit clause is not applied until after all rows to be returned are calculated so calling has_rows provides no optimization versus calling ->all in controller and checking for results before sending to template. Also use HashRefInflator.
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
[% IF NOT results.has_rows %]
|
||||
<div class="span2 alert alert-info">No matching records.</div>
|
||||
[% ELSE %]
|
||||
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -11,7 +8,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% FOREACH row IN results.all %]
|
||||
[% FOREACH row IN results %]
|
||||
<tr>
|
||||
<td class="nd_center-cell"><a href="[% uri_for('/report/ipinventory') %]?subnet=[% row.subnet | uri %]&daterange=[% daterange | uri %]&limit=[% row.subnet_size | uri %]">
|
||||
[% row.subnet | html_entity %]</a></td>
|
||||
@@ -22,5 +19,3 @@
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[% USE CSV %]
|
||||
[% CSV.dump([ 'Subnet' 'Size' 'Number of Active Nodes' 'Percent Utilization' ]) %]
|
||||
|
||||
[% FOREACH row IN results.all %]
|
||||
[% FOREACH row IN results %]
|
||||
[% mylist = [] %]
|
||||
[% mylist.push(row.subnet) %]
|
||||
[% mylist.push(row.subnet_size) %]
|
||||
|
||||
Reference in New Issue
Block a user