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

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 50 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::ApRadioChannelPower;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin::DBIC;
5 use Dancer::Plugin::Auth::Extensible;
6 use App::Netdisco::Util::ExpandParams 'expand_hash';
7  
8 use App::Netdisco::Web::Plugin;
9  
10 register_report(
11 { category => 'Wireless',
12 tag => 'apradiochannelpower',
13 label => 'Access Point Radios Channel and Power',
14 provides_csv => 1,
15 api_endpoint => 1,
16 }
17 );
18  
19 get '/ajax/content/report/apradiochannelpower/data' => require_login sub {
20 send_error( 'Missing parameter', 400 )
21 unless ( param('draw') && param('draw') =~ /\d+/ );
22  
23 my $rs = schema(vars->{'tenant'})->resultset('Virtual::ApRadioChannelPower');
24 my $exp_params = expand_hash( scalar params );
25 my $recordsTotal = $rs->count;
26 my @data = $rs->get_datatables_data($exp_params)->hri->all;
27 my $recordsFiltered = $rs->get_datatables_filtered_count($exp_params);
28  
29 content_type 'application/json';
30 return to_json(
31 { draw => int( param('draw') ),
32 recordsTotal => int($recordsTotal),
33 recordsFiltered => int($recordsFiltered),
34 data => \@data,
35 }
36 );
37 };
38  
39 get '/ajax/content/report/apradiochannelpower' => require_login sub {
40  
41 if ( request->is_ajax ) {
42 template 'ajax/report/apradiochannelpower.tt', {}, { layout => 'noop' };
43 }
44 else {
45 my @results
46 = schema(vars->{'tenant'})->resultset('Virtual::ApRadioChannelPower')
47 ->hri->all;
48  
49 return unless scalar @results;
50  
51 header( 'Content-Type' => 'text/comma-separated-values' );
52 template 'ajax/report/apradiochannelpower_csv.tt',
53 { results => \@results, }, { layout => 'noop' };
54 }
55 };
56  
57 1;