1package App::Netdisco::DB::Result::Virtual::ApRadioChannelPower;
2
3use strict;
4use warnings;
5
6use 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
13SELECT 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
27FROM device_port_wireless AS w
28JOIN device_port AS dp ON dp.port = w.port
29AND dp.ip = w.ip
30JOIN device AS d ON d.ip = w.ip
31WHERE w.channel != '0'
32ENDSQL
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
711;
72