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

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 40 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::PortBlocking;
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 => 'portblocking',
12 label => 'Blocked - Spanning Tree',
13 provides_csv => 1,
14 api_endpoint => 1,
15 }
16 );
17  
18 get '/ajax/content/report/portblocking' => require_login sub {
19 my @results = schema(vars->{'tenant'})->resultset('Device')->search(
20 { 'stp' => [ 'blocking', 'broken' ], 'up' => { '!=', 'down' } },
21 { select => [ 'ip', 'dns', 'name' ],
22 join => ['ports'],
23 '+columns' => [
24 { 'port' => 'ports.port' },
25 { 'description' => 'ports.name' },
26 { 'stp' => 'ports.stp' },
27 ]
28 }
29 )->hri->all;
30  
31 return unless scalar @results;
32  
33 if ( request->is_ajax ) {
34 my $json = to_json (\@results);
35 template 'ajax/report/portblocking.tt', { results => $json }, { layout => 'noop' };
36 }
37 else {
38 header( 'Content-Type' => 'text/comma-separated-values' );
39 template 'ajax/report/portblocking_csv.tt',
40 { results => \@results, }, { layout => 'noop' };
41 }
42 };
43  
44 1;