« blib/lib/App/Netdisco/DB/Result/Virtual/ActiveNodeWithAge.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/CidrIps.pm »
| 1 | package App::Netdisco::DB::Result::Virtual::ApRadioChannelPower; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use base 'DBIx::Class::Core'; | ||
| 7 | |||
| 8 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 9 | |||
| 10 | __PACKAGE__->table('ap_radio_channel_power'); | ||
| 11 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 12 | __PACKAGE__->result_source_instance->view_definition(<<ENDSQL | ||
| 13 | SELECT w.channel, | ||
| 14 | w.power, | ||
| 15 | w.ip, | ||
| 16 | w.port, | ||
| 17 | dp.name AS port_name, | ||
| 18 | dp.descr, | ||
| 19 | d.name AS device_name, | ||
| 20 | d.dns, | ||
| 21 | d.model, | ||
| 22 | d.location, | ||
| 23 | CASE | ||
| 24 | WHEN w.power > 0 THEN round((10.0 * log(w.power) / log(10))::numeric, 1) | ||
| 25 | ELSE NULL | ||
| 26 | END AS power2 | ||
| 27 | FROM device_port_wireless AS w | ||
| 28 | JOIN device_port AS dp ON dp.port = w.port | ||
| 29 | AND dp.ip = w.ip | ||
| 30 | JOIN device AS d ON d.ip = w.ip | ||
| 31 | WHERE w.channel != '0' | ||
| 32 | ENDSQL | ||
| 33 | ); | ||
| 34 | |||
| 35 | __PACKAGE__->add_columns( | ||
| 36 | 'channel' => { | ||
| 37 | data_type => 'integer', | ||
| 38 | }, | ||
| 39 | 'power' => { | ||
| 40 | data_type => 'integer', | ||
| 41 | }, | ||
| 42 | 'ip' => { | ||
| 43 | data_type => 'inet', | ||
| 44 | }, | ||
| 45 | 'port' => { | ||
| 46 | data_type => 'text', | ||
| 47 | }, | ||
| 48 | 'port_name' => { | ||
| 49 | data_type => 'text', | ||
| 50 | }, | ||
| 51 | 'descr' => { | ||
| 52 | data_type => 'text', | ||
| 53 | }, | ||
| 54 | 'device_name' => { | ||
| 55 | data_type => 'text', | ||
| 56 | }, | ||
| 57 | 'dns' => { | ||
| 58 | data_type => 'text', | ||
| 59 | }, | ||
| 60 | 'model' => { | ||
| 61 | data_type => 'text', | ||
| 62 | }, | ||
| 63 | 'location' => { | ||
| 64 | data_type => 'text', | ||
| 65 | }, | ||
| 66 | 'power2' => { | ||
| 67 | data_type => 'numeric', | ||
| 68 | }, | ||
| 69 | ); | ||
| 70 | |||
| 71 | 1; |