blib/lib/App/Netdisco/DB/Result/Virtual/UnDirEdgesAgg.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 19 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Netdisco::DB::Result::Virtual::UnDirEdgesAgg;
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('undir_edges_agg');
11 __PACKAGE__->result_source_instance->is_virtual(1);
12 __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
13 SELECT left_ip,
14 array_agg(right_ip) AS links
15 FROM
16 ( SELECT dp.ip AS left_ip,
17 di.ip AS right_ip
18 FROM
19 (SELECT device_port.ip,
20 device_port.remote_ip
21 FROM device_port
22 WHERE device_port.remote_port IS NOT NULL
23 GROUP BY device_port.ip,
24 device_port.remote_ip) dp
25 LEFT JOIN device_ip_resolved di ON dp.remote_ip = di.alias
26 WHERE di.ip IS NOT NULL
27 UNION SELECT di.ip AS left_ip,
28 dp.ip AS right_ip
29 FROM
30 (SELECT device_port.ip,
31 device_port.remote_ip
32 FROM device_port
33 WHERE device_port.remote_port IS NOT NULL
34 GROUP BY device_port.ip,
35 device_port.remote_ip) dp
36 LEFT JOIN device_ip_resolved di ON dp.remote_ip = di.alias
37 WHERE di.ip IS NOT NULL ) AS foo
38 GROUP BY left_ip
39 ORDER BY left_ip
40 ENDSQL
41  
42 __PACKAGE__->add_columns(
43 'left_ip' => {
44 data_type => 'inet',
45 },
46 'links' => {
47 data_type => 'inet[]',
48 }
49 );
50  
51 __PACKAGE__->belongs_to('device', 'App::Netdisco::DB::Result::Device',
52 { 'foreign.ip' => 'self.left_ip' });
53  
54 1;