Correct date formatting and logic in IP Inventory report
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
* [#84] No longer use dns as a key into devices; cope with dupe dns (LT)
|
* [#84] No longer use dns as a key into devices; cope with dupe dns (LT)
|
||||||
|
* Correct date formatting and logic in IP Inventory report
|
||||||
|
|
||||||
2.022000 - 2014-01-26
|
2.022000 - 2014-01-26
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
'dns',
|
'dns',
|
||||||
\'true AS active',
|
\'true AS active',
|
||||||
\'false AS node',
|
\'false AS node',
|
||||||
\'age(device.last_discover) AS age'
|
\qq/replace( date_trunc( 'minute', age( now(), device.last_discover ) ) ::text, 'mon', 'month') AS age/
|
||||||
],
|
],
|
||||||
as => [qw( ip time_first time_last dns active node age)],
|
as => [qw( ip time_first time_last dns active node age)],
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,9 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
||||||
undef,
|
undef,
|
||||||
{ columns => [qw( ip time_first time_last dns active)],
|
{ columns => [qw( ip time_first time_last dns active)],
|
||||||
'+select' => [ \'true AS node', \'age(time_last) AS age' ],
|
'+select' => [ \'true AS node',
|
||||||
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
||||||
|
],
|
||||||
'+as' => [ 'node', 'age' ],
|
'+as' => [ 'node', 'age' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
@@ -84,7 +86,8 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
{ columns => [qw( ip time_first time_last )],
|
{ columns => [qw( ip time_first time_last )],
|
||||||
'+select' => [
|
'+select' => [
|
||||||
'nbname AS dns', 'active',
|
'nbname AS dns', 'active',
|
||||||
\'true AS node', \'age(time_last) AS age'
|
\'true AS node',
|
||||||
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
||||||
],
|
],
|
||||||
'+as' => [ 'dns', 'active', 'node', 'age' ],
|
'+as' => [ 'dns', 'active', 'node', 'age' ],
|
||||||
}
|
}
|
||||||
@@ -99,7 +102,9 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
undef,
|
undef,
|
||||||
{ bind => [ $subnet->cidr ],
|
{ bind => [ $subnet->cidr ],
|
||||||
columns => [qw( ip time_first time_last dns active)],
|
columns => [qw( ip time_first time_last dns active)],
|
||||||
'+select' => [ \'false AS node', \'age(time_last) AS age' ],
|
'+select' => [ \'false AS node',
|
||||||
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
||||||
|
],
|
||||||
'+as' => [ 'node', 'age' ],
|
'+as' => [ 'node', 'age' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
@@ -113,8 +118,8 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
select => [
|
select => [
|
||||||
\'DISTINCT ON (ip) ip',
|
\'DISTINCT ON (ip) ip',
|
||||||
'dns',
|
'dns',
|
||||||
\'date_trunc(\'second\', time_last) AS time_last',
|
\qq/date_trunc('second', time_last) AS time_last/,
|
||||||
\'date_trunc(\'second\', time_first) AS time_first',
|
\qq/date_trunc('second', time_first) AS time_first/,
|
||||||
'active',
|
'active',
|
||||||
'node',
|
'node',
|
||||||
'age'
|
'age'
|
||||||
@@ -134,8 +139,8 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
if ( $agenot ) {
|
if ( $agenot ) {
|
||||||
$rs = $rs_union->search(
|
$rs = $rs_union->search(
|
||||||
{ -or => [
|
{ -or => [
|
||||||
time_first => [ { '<', $start }, undef ],
|
time_first => [ undef ],
|
||||||
time_last => { '>', $end },
|
time_last => [ { '<', $start }, { '>', $end } ]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ from => { me => $rs_sub }, }
|
{ from => { me => $rs_sub }, }
|
||||||
@@ -144,8 +149,8 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
else {
|
else {
|
||||||
$rs = $rs_union->search(
|
$rs = $rs_union->search(
|
||||||
{ -and => [
|
{ -and => [
|
||||||
time_first => { '>=', $start },
|
time_last => { '>=', $start },
|
||||||
time_last => { '<=', $end },
|
time_last => { '<=', $end },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ from => { me => $rs_sub }, }
|
{ from => { me => $rs_sub }, }
|
||||||
|
|||||||
@@ -21,17 +21,7 @@
|
|||||||
<td>[% row.ip | html_entity %]</td>
|
<td>[% row.ip | html_entity %]</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
<td class="nd_center-cell">[% row.dns | html_entity %]</td>
|
<td class="nd_center-cell">[% row.dns | html_entity %]</td>
|
||||||
[% IF row.age %]
|
<td class="nd_center-cell">[% row.age || 'Never' | html_entity %]</td>
|
||||||
[% age = row.age.replace('mon', 'month') %]
|
|
||||||
[% IF age.match('(day|month|year)') %]
|
|
||||||
[% age = age.remove('(-)?\d{2}:\d{2}.*$') %]
|
|
||||||
[% ELSE %]
|
|
||||||
[% age = age.replace('(\d{2}:\d{2}):\d{2}(\.\d*)$', '$1') %]
|
|
||||||
[% END %]
|
|
||||||
[% ELSE %]
|
|
||||||
[% age = 'Never' %]
|
|
||||||
[% END %]
|
|
||||||
<td class="nd_center-cell">[% age | html_entity %]</td>
|
|
||||||
<td class="nd_center-cell">[% row.time_first || 'Never' | html_entity %]</td>
|
<td class="nd_center-cell">[% row.time_first || 'Never' | html_entity %]</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
Reference in New Issue
Block a user