| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPAN::Testers::API::Controller::Summary; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.020'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: API for test report summary data |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
6
|
|
|
|
|
|
|
#pod |
|
7
|
|
|
|
|
|
|
#pod This API accesses the test report summaries, which are a few fields picked out of |
|
8
|
|
|
|
|
|
|
#pod the larger test report data structure that are useful for reporting. |
|
9
|
|
|
|
|
|
|
#pod |
|
10
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
11
|
|
|
|
|
|
|
#pod |
|
12
|
|
|
|
|
|
|
#pod =over |
|
13
|
|
|
|
|
|
|
#pod |
|
14
|
|
|
|
|
|
|
#pod =item L<CPAN::Testers::Schema::Result::Stats> |
|
15
|
|
|
|
|
|
|
#pod |
|
16
|
|
|
|
|
|
|
#pod =item L<Mojolicious::Controller> |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod =back |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod =cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
10346
|
use Mojo::Base 'Mojolicious::Controller'; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
14
|
|
|
23
|
1
|
|
|
1
|
|
309
|
use CPAN::Testers::API::Base; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
18
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#pod =method summary |
|
26
|
|
|
|
|
|
|
#pod |
|
27
|
|
|
|
|
|
|
#pod ### Requests: |
|
28
|
|
|
|
|
|
|
#pod GET /v3/summary/My-Dist/1.000 |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod ### Response: |
|
31
|
|
|
|
|
|
|
#pod 200 OK |
|
32
|
|
|
|
|
|
|
#pod Content-Type: application/json |
|
33
|
|
|
|
|
|
|
#pod |
|
34
|
|
|
|
|
|
|
#pod [ |
|
35
|
|
|
|
|
|
|
#pod { |
|
36
|
|
|
|
|
|
|
#pod "guid": "00000000-0000-0000-0000-0000000000001", |
|
37
|
|
|
|
|
|
|
#pod "id": 1, |
|
38
|
|
|
|
|
|
|
#pod "grade": "pass", |
|
39
|
|
|
|
|
|
|
#pod "dist": "My-Dist", |
|
40
|
|
|
|
|
|
|
#pod "version": "1.000", |
|
41
|
|
|
|
|
|
|
#pod "tester": "doug@example.com (Doug Bell)", |
|
42
|
|
|
|
|
|
|
#pod "platform": "darwin", |
|
43
|
|
|
|
|
|
|
#pod "perl": "5.22.0", |
|
44
|
|
|
|
|
|
|
#pod "osname": "darwin", |
|
45
|
|
|
|
|
|
|
#pod "osvers": "10.8.0" |
|
46
|
|
|
|
|
|
|
#pod } |
|
47
|
|
|
|
|
|
|
#pod ] |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod Get test report summary data for the given distribution and version. |
|
50
|
|
|
|
|
|
|
#pod |
|
51
|
|
|
|
|
|
|
#pod Report summary data contains a select set of fields from the full test |
|
52
|
|
|
|
|
|
|
#pod report. These fields are the most useful ones for building aggregate |
|
53
|
|
|
|
|
|
|
#pod reporting and graphs for dashboards. |
|
54
|
|
|
|
|
|
|
#pod |
|
55
|
|
|
|
|
|
|
#pod =cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
2
|
1
|
6494
|
sub summary( $c ) { |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
7
|
|
|
58
|
2
|
50
|
|
|
|
29
|
$c->openapi->valid_input or return; |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
5094
|
my $dist = $c->validation->param( 'dist' ); |
|
61
|
2
|
|
|
|
|
95
|
my $version = $c->validation->param( 'version' ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
83
|
my $rs = $c->schema->resultset( 'Stats' ); |
|
64
|
2
|
|
|
|
|
1507
|
$rs = $rs->search( |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
|
|
|
|
|
|
dist => $dist, |
|
67
|
|
|
|
|
|
|
version => $version, |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
columns => [qw( guid fulldate state tester dist version platform perl osname osvers )], |
|
71
|
|
|
|
|
|
|
# Only get hashrefs out |
|
72
|
|
|
|
|
|
|
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
); |
|
75
|
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
1160
|
my @results = $rs->all; |
|
77
|
2
|
100
|
|
|
|
9900
|
if ( !@results ) { |
|
78
|
1
|
|
|
|
|
33
|
return $c->render_error( 404, sprintf 'No results found for dist "%s" version "%s"', $dist, $version ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
5
|
for my $result ( @results ) { |
|
82
|
2
|
|
|
|
|
9
|
$result->{grade} = delete $result->{state}; |
|
83
|
2
|
|
|
|
|
12
|
$result->{date} = _format_date( delete $result->{fulldate} ); |
|
84
|
2
|
|
|
|
|
8
|
$result->{reporter} = delete $result->{tester}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
18
|
return $c->render( |
|
88
|
|
|
|
|
|
|
openapi => \@results, |
|
89
|
|
|
|
|
|
|
); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
2
|
|
|
2
|
|
7
|
sub _format_date( $fulldate ) { |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
6
|
|
|
93
|
2
|
|
|
|
|
20
|
my ( $y, $m, $d, $h, $n ) = $fulldate =~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/; |
|
94
|
2
|
|
|
|
|
19
|
return "$y-$m-${d}T$h:$n:00Z"; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
CPAN::Testers::API::Controller::Summary - API for test report summary data |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
version 0.020 |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This API accesses the test report summaries, which are a few fields picked out of |
|
114
|
|
|
|
|
|
|
the larger test report data structure that are useful for reporting. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 METHODS |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 summary |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
### Requests: |
|
121
|
|
|
|
|
|
|
GET /v3/summary/My-Dist/1.000 |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
### Response: |
|
124
|
|
|
|
|
|
|
200 OK |
|
125
|
|
|
|
|
|
|
Content-Type: application/json |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
[ |
|
128
|
|
|
|
|
|
|
{ |
|
129
|
|
|
|
|
|
|
"guid": "00000000-0000-0000-0000-0000000000001", |
|
130
|
|
|
|
|
|
|
"id": 1, |
|
131
|
|
|
|
|
|
|
"grade": "pass", |
|
132
|
|
|
|
|
|
|
"dist": "My-Dist", |
|
133
|
|
|
|
|
|
|
"version": "1.000", |
|
134
|
|
|
|
|
|
|
"tester": "doug@example.com (Doug Bell)", |
|
135
|
|
|
|
|
|
|
"platform": "darwin", |
|
136
|
|
|
|
|
|
|
"perl": "5.22.0", |
|
137
|
|
|
|
|
|
|
"osname": "darwin", |
|
138
|
|
|
|
|
|
|
"osvers": "10.8.0" |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
] |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Get test report summary data for the given distribution and version. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Report summary data contains a select set of fields from the full test |
|
145
|
|
|
|
|
|
|
report. These fields are the most useful ones for building aggregate |
|
146
|
|
|
|
|
|
|
reporting and graphs for dashboards. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item L<CPAN::Testers::Schema::Result::Stats> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item L<Mojolicious::Controller> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Doug Bell <preaction@cpan.org> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Doug Bell. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
167
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |