File Coverage

blib/lib/BenchmarkAnything/Storage/Frontend/HTTP/Controller/Submit.pm
Criterion Covered Total %
statement 9 13 69.2
branch 2 4 50.0
condition n/a
subroutine 2 2 100.0
pod 1 1 100.0
total 14 20 70.0


line stmt bran cond sub pod time code
1             package BenchmarkAnything::Storage::Frontend::HTTP::Controller::Submit;
2             our $AUTHORITY = 'cpan:SCHWIGON';
3             # ABSTRACT: BenchmarkAnything - REST API - data submit
4             $BenchmarkAnything::Storage::Frontend::HTTP::Controller::Submit::VERSION = '0.010';
5 1     1   7933 use Mojo::Base 'Mojolicious::Controller';
  1         2  
  1         7  
6              
7              
8             sub add
9             {
10 5     5 1 364981 my ($self) = @_;
11              
12 5         20 my $data = $self->req->json;
13              
14 5 50       4669 if ($data)
15             {
16 5 50       20 if (!$ENV{HARNESS_ACTIVE}) {
17 0         0 my $orig = $self->app->balib->{queuemode};
18 0         0 $self->app->balib->{queuemode} = 1;
19 0         0 $self->app->balib->add($data);
20 0         0 $self->app->balib->{queuemode} = $orig;
21             } else {
22 5         22 $self->app->balib->add($data);
23             }
24             }
25             # how to report error?
26 5         1193480 $self->render;
27             }
28              
29             1;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             BenchmarkAnything::Storage::Frontend::HTTP::Controller::Submit - BenchmarkAnything - REST API - data submit
40              
41             =head2 add
42              
43             Parameters:
44              
45             =over 4
46              
47             =item * JSON request body
48              
49             If a JSON request is provided it is interpreted as an array of
50             BenchmarkAnything data points according to
51             L<BenchmarkAnything::Schema|BenchmarkAnything::Schema>, inclusive the
52             surrounding hash key C<BenchmarkAnythingData>.
53              
54             =back
55              
56             =head1 AUTHOR
57              
58             Steffen Schwigon <ss5@renormalist.net>
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2017 by Steffen Schwigon.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut