blib/lib/App/Netdisco/Web/API/Statistics.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran n/a Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 35 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::API::Statistics;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin::DBIC;
5 use Dancer::Plugin::Swagger;
6 use Dancer::Plugin::Auth::Extensible;
7  
8 use Try::Tiny;
9  
10 swagger_path {
11 tags => ['General'],
12 path => (setting('api_base') || '').'/statistics',
13 description => 'Returns the latest row from the statistics table',
14 parameters => [],
15 responses => { default => {} },
16  
17 }, get '/api/v1/statistics' => require_role api => sub {
18 my $stats = try {
19 schema(vars->{'tenant'})->resultset('Statistics')
20 ->search(undef, { order_by => { -desc => 'day' }, rows => 1 })->first
21 } or send_error('No statistics available', 404);
22  
23 return to_json $stats->TO_JSON;
24 };
25  
26 true;