« blib/lib/App/Netdisco/DB/Result/Virtual/ActiveNode.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm »
| 1 | use utf8; | ||
| 2 | package App::Netdisco::DB::Result::Virtual::ActiveNodeWithAge; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use base 'App::Netdisco::DB::Result::Virtual::ActiveNode'; | ||
| 8 | |||
| 9 | __PACKAGE__->load_components('Helper::Row::SubClass'); | ||
| 10 | __PACKAGE__->subclass; | ||
| 11 | |||
| 12 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 13 | __PACKAGE__->table("active_node_with_age"); | ||
| 14 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 15 | __PACKAGE__->result_source_instance->view_definition(q{ | ||
| 16 | SELECT *, | ||
| 17 | replace( date_trunc( 'minute', age( LOCALTIMESTAMP, time_last + interval '30 second' ) ) ::text, 'mon', 'month') | ||
| 18 | AS time_last_age | ||
| 19 | FROM node WHERE active | ||
| 20 | }); | ||
| 21 | |||
| 22 | __PACKAGE__->add_columns( | ||
| 23 | "time_last_age", | ||
| 24 | { data_type => "text", is_nullable => 1 }, | ||
| 25 | ); | ||
| 26 | |||
| 27 | 1; |