blib/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 39 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::Web::Plugin::Report::HalfDuplex;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin::DBIC;
5 use Dancer::Plugin::Auth::Extensible;
6  
7 use App::Netdisco::Web::Plugin;
8  
9 register_report(
10 { category => 'Port',
11 tag => 'halfduplex',
12 label => 'Ports in Half Duplex Mode',
13 provides_csv => 1,
14 api_endpoint => 1,
15 }
16 );
17  
18 get '/ajax/content/report/halfduplex' => require_login sub {
19 my @results
20 = schema(vars->{'tenant'})->resultset('DevicePort')
21 ->columns( [qw/ ip port name duplex /] )->search(
22 { up => 'up', duplex => { '-ilike' => 'half' } },
23 { '+columns' => [qw/ device.dns device.name /],
24 join => [qw/ device /],
25 collapse => 1,
26 }
27 )->order_by( [qw/ device.dns port /] )->hri->all;
28  
29 return unless scalar @results;
30  
31 if ( request->is_ajax ) {
32 my $json = to_json( \@results );
33 template 'ajax/report/halfduplex.tt', { results => $json }, { layout => 'noop' };
34 }
35 else {
36 header( 'Content-Type' => 'text/comma-separated-values' );
37 template 'ajax/report/halfduplex_csv.tt',
38 { results => \@results }, { layout => 'noop' };
39 }
40 };
41  
42 1;