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

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 38 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::PortAdminDown;
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 => 'portadmindown',
12 label => 'Ports Administratively Disabled',
13 provides_csv => 1,
14 api_endpoint => 1,
15 }
16 );
17  
18 get '/ajax/content/report/portadmindown' => require_login sub {
19 my @results = schema(vars->{'tenant'})->resultset('Device')->search(
20 { 'up_admin' => 'down' },
21 { select => [ 'ip', 'dns', 'name' ],
22 join => [ 'ports' ],
23 '+columns' => [
24 { 'port' => 'ports.port' },
25 { 'description' => 'ports.name' },
26 { 'up_admin' => 'ports.up_admin' },
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/portadmindown.tt', { results => $json }, { layout => 'noop' };
36 }
37 else {
38 header( 'Content-Type' => 'text/comma-separated-values' );
39 template 'ajax/report/portadmindown_csv.tt',
40 { results => \@results, }, { layout => 'noop' };
41 }
42 };
43  
44 1;