line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Testers::API::Controller::Release; |
2
|
|
|
|
|
|
|
our $VERSION = '0.018'; |
3
|
|
|
|
|
|
|
# ABSTRACT: API for test reports collected by CPAN release |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
6
|
|
|
|
|
|
|
#pod |
7
|
|
|
|
|
|
|
#pod This API accesses summary data collected by CPAN release. So, if you |
8
|
|
|
|
|
|
|
#pod just want to know how many PASS and FAIL reports a single distribution |
9
|
|
|
|
|
|
|
#pod has for each version released, this is the best API. |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod =over |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod =item L<CPAN::Testers::Schema::Result::Release> |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod =item L<Mojolicious::Controller> |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =back |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =cut |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
4116
|
use Mojo::Base 'Mojolicious::Controller'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
24
|
1
|
|
|
1
|
|
185
|
use CPAN::Testers::API::Base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#pod =method release |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod ### Requests: |
29
|
|
|
|
|
|
|
#pod GET /v1/release |
30
|
|
|
|
|
|
|
#pod GET /v1/release?since=2016-01-01T12:34:00Z |
31
|
|
|
|
|
|
|
#pod GET /v1/release/dist/My-Dist |
32
|
|
|
|
|
|
|
#pod GET /v1/release/dist/My-Dist?since=2016-01-01T12:34:00Z |
33
|
|
|
|
|
|
|
#pod GET /v1/release/author/PREACTION |
34
|
|
|
|
|
|
|
#pod GET /v1/release/author/PREACTION?since=2016-01-01T12:34:00Z |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod ### Response: |
37
|
|
|
|
|
|
|
#pod 200 OK |
38
|
|
|
|
|
|
|
#pod Content-Type: application/json |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod [ |
41
|
|
|
|
|
|
|
#pod { |
42
|
|
|
|
|
|
|
#pod "dist": "My-Dist", |
43
|
|
|
|
|
|
|
#pod "version": "1.000", |
44
|
|
|
|
|
|
|
#pod "pass": 34, |
45
|
|
|
|
|
|
|
#pod "fail": 2, |
46
|
|
|
|
|
|
|
#pod "na": 1, |
47
|
|
|
|
|
|
|
#pod "unknown": 0 |
48
|
|
|
|
|
|
|
#pod } |
49
|
|
|
|
|
|
|
#pod ] |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod Get release data. Results can be limited by distribution (with the |
52
|
|
|
|
|
|
|
#pod C<dist> key in the stash), by author (with the C<author> key in the |
53
|
|
|
|
|
|
|
#pod stash), and by date (with the C<since> query parameter). |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod Release data contains a summary of the pass, fail, na, and unknown test |
56
|
|
|
|
|
|
|
#pod results created by stable Perls. Development Perls (odd-numbered 5.XX |
57
|
|
|
|
|
|
|
#pod releases) are not included. |
58
|
|
|
|
|
|
|
#pod |
59
|
|
|
|
|
|
|
#pod =cut |
60
|
|
|
|
|
|
|
|
61
|
18
|
|
|
18
|
1
|
41069
|
sub release( $c ) { |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
29
|
|
62
|
18
|
100
|
|
|
|
137
|
$c->openapi->valid_input or return; |
63
|
|
|
|
|
|
|
|
64
|
16
|
|
|
|
|
15066
|
my $rs = $c->schema->resultset( 'Release' ); |
65
|
16
|
|
|
|
|
6201
|
$rs = $rs->search( |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
perlmat => 1, # only stable perls |
68
|
|
|
|
|
|
|
patched => 1, # not patched perls |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
columns => [qw( dist version pass fail na unknown )], |
72
|
|
|
|
|
|
|
# Only get hashrefs out |
73
|
|
|
|
|
|
|
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Only allow "since" for "dist" and "author" because the query can |
78
|
|
|
|
|
|
|
# not be optimized to return in a reasonable time. |
79
|
16
|
100
|
|
|
|
5143
|
if ( my $since = $c->param( 'since' ) ) { |
80
|
6
|
100
|
100
|
|
|
540
|
unless ( $c->validation->param( 'dist' ) || $c->validation->param( 'author' ) ) { |
81
|
2
|
|
|
|
|
98
|
return $c->render_error( 400 => '"since" parameter not allowed' ); |
82
|
|
|
|
|
|
|
} |
83
|
4
|
|
|
|
|
155
|
$rs = $rs->since( $since ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
14
|
|
|
|
|
2956
|
my @results; |
87
|
14
|
100
|
|
|
|
42
|
if ( my $dist = $c->validation->param( 'dist' ) ) { |
|
|
100
|
|
|
|
|
|
88
|
6
|
|
|
|
|
169
|
$rs = $rs->by_dist( $dist ); |
89
|
6
|
|
|
|
|
2394
|
@results = $rs->all; |
90
|
6
|
100
|
|
|
|
26729
|
if ( !@results ) { |
91
|
2
|
|
|
|
|
21
|
return $c->render_error( 404, sprintf 'Distribution "%s" not found', $dist ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
elsif ( my $author = $c->validation->param( 'author' ) ) { |
95
|
6
|
|
|
|
|
263
|
@results = $rs->by_author( $author )->all; |
96
|
6
|
100
|
|
|
|
50518
|
if ( !@results ) { |
97
|
2
|
|
|
|
|
135
|
return $c->render_error( 404, sprintf 'Author "%s" not found', $author ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
2
|
|
|
|
|
83
|
@results = $rs->all; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
10
|
|
|
|
|
5482
|
return $c->render( |
105
|
|
|
|
|
|
|
openapi => \@results, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=pod |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 NAME |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
CPAN::Testers::API::Controller::Release - API for test reports collected by CPAN release |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 VERSION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
version 0.018 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This API accesses summary data collected by CPAN release. So, if you |
126
|
|
|
|
|
|
|
just want to know how many PASS and FAIL reports a single distribution |
127
|
|
|
|
|
|
|
has for each version released, this is the best API. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 METHODS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 release |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
### Requests: |
134
|
|
|
|
|
|
|
GET /v1/release |
135
|
|
|
|
|
|
|
GET /v1/release?since=2016-01-01T12:34:00Z |
136
|
|
|
|
|
|
|
GET /v1/release/dist/My-Dist |
137
|
|
|
|
|
|
|
GET /v1/release/dist/My-Dist?since=2016-01-01T12:34:00Z |
138
|
|
|
|
|
|
|
GET /v1/release/author/PREACTION |
139
|
|
|
|
|
|
|
GET /v1/release/author/PREACTION?since=2016-01-01T12:34:00Z |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
### Response: |
142
|
|
|
|
|
|
|
200 OK |
143
|
|
|
|
|
|
|
Content-Type: application/json |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
[ |
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
"dist": "My-Dist", |
148
|
|
|
|
|
|
|
"version": "1.000", |
149
|
|
|
|
|
|
|
"pass": 34, |
150
|
|
|
|
|
|
|
"fail": 2, |
151
|
|
|
|
|
|
|
"na": 1, |
152
|
|
|
|
|
|
|
"unknown": 0 |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
] |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Get release data. Results can be limited by distribution (with the |
157
|
|
|
|
|
|
|
C<dist> key in the stash), by author (with the C<author> key in the |
158
|
|
|
|
|
|
|
stash), and by date (with the C<since> query parameter). |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Release data contains a summary of the pass, fail, na, and unknown test |
161
|
|
|
|
|
|
|
results created by stable Perls. Development Perls (odd-numbered 5.XX |
162
|
|
|
|
|
|
|
releases) are not included. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item L<CPAN::Testers::Schema::Result::Release> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item L<Mojolicious::Controller> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Doug Bell <preaction@cpan.org> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Doug Bell. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
183
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |