#24 Show device age in device search view
This commit is contained in:
@@ -332,6 +332,19 @@ The format is in "X days/months/years" style, similar to:
|
||||
|
||||
sub uptime_age { return (shift)->get_column('uptime_age') }
|
||||
|
||||
=head2 first_seen_stamp
|
||||
|
||||
Formatted version of the C<creation> field, accurate to the minute.
|
||||
|
||||
The format is somewhat like ISO 8601 or RFC3339 but without the middle C<T>
|
||||
between the date stamp and time stamp. That is:
|
||||
|
||||
2012-02-06 12:49
|
||||
|
||||
=cut
|
||||
|
||||
sub first_seen_stamp { return (shift)->get_column('first_seen_stamp') }
|
||||
|
||||
=head2 last_discover_stamp
|
||||
|
||||
Formatted version of the C<last_discover> field, accurate to the minute.
|
||||
|
||||
@@ -16,12 +16,22 @@ will add the following additional synthesized columns to the result set:
|
||||
|
||||
=item uptime_age
|
||||
|
||||
=item first_seen_stamp
|
||||
|
||||
=item last_discover_stamp
|
||||
|
||||
=item last_macsuck_stamp
|
||||
|
||||
=item last_arpnip_stamp
|
||||
|
||||
=item since_first_seen
|
||||
|
||||
=item since_last_discover
|
||||
|
||||
=item since_last_macsuck
|
||||
|
||||
=item since_last_arpnip
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -36,9 +46,11 @@ sub with_times {
|
||||
'+columns' => {
|
||||
uptime_age => \("replace(age(timestamp 'epoch' + uptime / 100 * interval '1 second', "
|
||||
."timestamp '1970-01-01 00:00:00-00')::text, 'mon', 'month')"),
|
||||
first_seen_stamp => \"to_char(creation, 'YYYY-MM-DD HH24:MI')",
|
||||
last_discover_stamp => \"to_char(last_discover, 'YYYY-MM-DD HH24:MI')",
|
||||
last_macsuck_stamp => \"to_char(last_macsuck, 'YYYY-MM-DD HH24:MI')",
|
||||
last_arpnip_stamp => \"to_char(last_arpnip, 'YYYY-MM-DD HH24:MI')",
|
||||
since_first_seen => \"extract(epoch from (age(now(), creation)))",
|
||||
since_last_discover => \"extract(epoch from (age(now(), last_discover)))",
|
||||
since_last_macsuck => \"extract(epoch from (age(now(), last_macsuck)))",
|
||||
since_last_arpnip => \"extract(epoch from (age(now(), last_arpnip)))",
|
||||
|
||||
@@ -19,7 +19,7 @@ get '/ajax/content/search/device' => require_login sub {
|
||||
|
||||
if ($has_opt) {
|
||||
$rs = schema('netdisco')->resultset('Device')->columns(
|
||||
[ "ip", "dns", "name", "contact",
|
||||
[ "ip", "dns", "name",
|
||||
"location", "model", "os_ver", "serial"
|
||||
]
|
||||
)->with_times->search_by_field( scalar params );
|
||||
@@ -29,7 +29,7 @@ get '/ajax/content/search/device' => require_login sub {
|
||||
send_error( 'Missing query', 400 ) unless $q;
|
||||
|
||||
$rs = schema('netdisco')->resultset('Device')->columns(
|
||||
[ "ip", "dns", "name", "contact",
|
||||
[ "ip", "dns", "name",
|
||||
"location", "model", "os_ver", "serial"
|
||||
]
|
||||
)->with_times->search_fuzzy($q);
|
||||
|
||||
Reference in New Issue
Block a user