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

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 36 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::ApChannelDist;
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 => 'Wireless',
11 tag => 'apchanneldist',
12 label => 'Access Point Channel Distribution',
13 provides_csv => 1,
14 api_endpoint => 1,
15 }
16 );
17  
18 get '/ajax/content/report/apchanneldist' => require_login sub {
19 my @results = schema(vars->{'tenant'})->resultset('DevicePortWireless')->search(
20 { channel => { '!=', '0' } },
21 { select => [ 'channel', { count => 'channel' } ],
22 as => [qw/ channel ch_count /],
23 group_by => [qw/channel/],
24 order_by => { -desc => [qw/count/] },
25 },
26 )->hri->all;
27  
28 return unless scalar @results;
29  
30 if ( request->is_ajax ) {
31 my $json = to_json( \@results );
32 template 'ajax/report/apchanneldist.tt', { results => $json }, { layout => 'noop' };
33 }
34 else {
35 header( 'Content-Type' => 'text/comma-separated-values' );
36 template 'ajax/report/apchanneldist_csv.tt', { results => \@results }, { layout => 'noop' };
37 }
38 };
39  
40 1;