line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Testers::Schema::Result::TestReport; |
2
|
|
|
|
|
|
|
our $VERSION = '0.024'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Raw reports as JSON documents |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
6
|
|
|
|
|
|
|
#pod |
7
|
|
|
|
|
|
|
#pod my $schema = CPAN::Testers::Schema->connect( $dsn, $user, $pass ); |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod # Retrieve a row |
10
|
|
|
|
|
|
|
#pod my $row = $schema->resultset( 'TestReport' )->first; |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod This table contains the raw reports as submitted by the tester. From this, |
15
|
|
|
|
|
|
|
#pod the L<statistics table|CPAN::Testers::Schema::Result::Stats> is generated |
16
|
|
|
|
|
|
|
#pod by L<CPAN::Testers::Backend::ProcessReports>. |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod L<DBIx::Class::Row>, L<CPAN::Testers::Schema> |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod =cut |
23
|
|
|
|
|
|
|
|
24
|
13
|
|
|
13
|
|
34066
|
use CPAN::Testers::Schema::Base 'Result'; |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
134
|
|
25
|
13
|
|
|
13
|
|
6680
|
use Data::UUID; |
|
13
|
|
|
|
|
9314
|
|
|
13
|
|
|
|
|
913
|
|
26
|
13
|
|
|
13
|
|
113
|
use DateTime; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
335
|
|
27
|
13
|
|
|
13
|
|
6076
|
use JSON::MaybeXS; |
|
13
|
|
|
|
|
17259
|
|
|
13
|
|
|
|
|
6495
|
|
28
|
|
|
|
|
|
|
table 'test_report'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__PACKAGE__->load_components('InflateColumn::DateTime', 'Core'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#pod =attr id |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod The UUID of this report stored in standard hex string representation. |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
primary_column 'id', { |
39
|
|
|
|
|
|
|
data_type => 'char', |
40
|
|
|
|
|
|
|
size => 36, |
41
|
|
|
|
|
|
|
is_nullable => 0, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#pod =attr created |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod The ISO8601 date/time of when the report was inserted into the database. |
47
|
|
|
|
|
|
|
#pod Will default to the current time. |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod The JSON report also contains a C<created> field. This is the date/time |
50
|
|
|
|
|
|
|
#pod that the report was created on the reporter's machine. |
51
|
|
|
|
|
|
|
#pod |
52
|
|
|
|
|
|
|
#pod =cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
column created => { |
55
|
|
|
|
|
|
|
data_type => 'datetime', |
56
|
|
|
|
|
|
|
is_nullable => 0, |
57
|
|
|
|
|
|
|
format_datetime => 1, |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#pod =attr report |
61
|
|
|
|
|
|
|
#pod |
62
|
|
|
|
|
|
|
#pod The full JSON report. |
63
|
|
|
|
|
|
|
#pod |
64
|
|
|
|
|
|
|
#pod XXX: Describe the format a little and link to the main schema OpenAPI |
65
|
|
|
|
|
|
|
#pod format on http://api.cpantesters.org |
66
|
|
|
|
|
|
|
#pod |
67
|
|
|
|
|
|
|
#pod The serializer for this column will convert UTF-8 characters into their |
68
|
|
|
|
|
|
|
#pod corresponding C<\u####> escape sequence, so this column is safe for |
69
|
|
|
|
|
|
|
#pod tables with Latin1 encoding. |
70
|
|
|
|
|
|
|
#pod |
71
|
|
|
|
|
|
|
#pod =cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
column 'report', { |
74
|
|
|
|
|
|
|
data_type => 'JSON', |
75
|
|
|
|
|
|
|
is_nullable => 0, |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my %JSON_OPT = ( |
79
|
|
|
|
|
|
|
allow_blessed => 1, |
80
|
|
|
|
|
|
|
convert_blessed => 1, |
81
|
|
|
|
|
|
|
ascii => 1, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
__PACKAGE__->inflate_column( report => { |
84
|
|
|
|
|
|
|
deflate => sub { |
85
|
|
|
|
|
|
|
my ( $ref, $row ) = @_; |
86
|
|
|
|
|
|
|
JSON::MaybeXS->new( %JSON_OPT )->encode( $ref ); |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
inflate => sub { |
89
|
|
|
|
|
|
|
my ( $raw, $row ) = @_; |
90
|
|
|
|
|
|
|
JSON::MaybeXS->new( %JSON_OPT )->decode( |
91
|
|
|
|
|
|
|
$raw =~ s/([\x{0000}-\x{001f}])/sprintf "\\u%v04x", $1/reg |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
}, |
94
|
|
|
|
|
|
|
} ); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#pod =method new |
97
|
|
|
|
|
|
|
#pod |
98
|
|
|
|
|
|
|
#pod Create a new object. This is called automatically by the ResultSet |
99
|
|
|
|
|
|
|
#pod object and should not be called directly. |
100
|
|
|
|
|
|
|
#pod |
101
|
|
|
|
|
|
|
#pod This is overridden to provide sane defaults for the C<id> and C<created> |
102
|
|
|
|
|
|
|
#pod fields. |
103
|
|
|
|
|
|
|
#pod |
104
|
|
|
|
|
|
|
#pod B<NOTE:> You should not supply a C<created> unless you are creating |
105
|
|
|
|
|
|
|
#pod reports in the past. Reports created in the past will be hidden from |
106
|
|
|
|
|
|
|
#pod many feeds, and may cause failures to not be reported to authors. |
107
|
|
|
|
|
|
|
#pod |
108
|
|
|
|
|
|
|
#pod =cut |
109
|
|
|
|
|
|
|
|
110
|
5
|
|
|
5
|
1
|
1625567
|
sub new( $class, $attrs ) { |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
12
|
|
111
|
5
|
|
66
|
|
|
1023
|
$attrs->{report}{id} = $attrs->{id} ||= Data::UUID->new->create_str; |
112
|
5
|
|
66
|
|
|
1087
|
$attrs->{created} ||= DateTime->now( time_zone => 'UTC' ); |
113
|
5
|
|
33
|
|
|
2048
|
$attrs->{report}{created} ||= $attrs->{created}->datetime . 'Z'; |
114
|
5
|
|
|
|
|
248
|
return $class->next::method( $attrs ); |
115
|
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#pod =method upload |
118
|
|
|
|
|
|
|
#pod |
119
|
|
|
|
|
|
|
#pod my $upload = $row->upload; |
120
|
|
|
|
|
|
|
#pod |
121
|
|
|
|
|
|
|
#pod Get the associated L<CPAN::Testers::Schema::Result::Upload> object for |
122
|
|
|
|
|
|
|
#pod the distribution tested by this test report. |
123
|
|
|
|
|
|
|
#pod |
124
|
|
|
|
|
|
|
#pod =cut |
125
|
|
|
|
|
|
|
|
126
|
1
|
|
|
1
|
1
|
1191
|
sub upload( $self ) { |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
127
|
1
|
|
|
|
|
31
|
my ( $dist, $vers ) = $self->report->{distribution}->@{qw( name version )}; |
128
|
1
|
|
|
|
|
34
|
return $self->result_source->schema->resultset( 'Upload' ) |
129
|
|
|
|
|
|
|
->search({ dist => $dist, version => $vers })->single; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=pod |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 NAME |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
CPAN::Testers::Schema::Result::TestReport - Raw reports as JSON documents |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 VERSION |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
version 0.024 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SYNOPSIS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $schema = CPAN::Testers::Schema->connect( $dsn, $user, $pass ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# Retrieve a row |
151
|
|
|
|
|
|
|
my $row = $schema->resultset( 'TestReport' )->first; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 DESCRIPTION |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This table contains the raw reports as submitted by the tester. From this, |
156
|
|
|
|
|
|
|
the L<statistics table|CPAN::Testers::Schema::Result::Stats> is generated |
157
|
|
|
|
|
|
|
by L<CPAN::Testers::Backend::ProcessReports>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 id |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The UUID of this report stored in standard hex string representation. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 created |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
The ISO8601 date/time of when the report was inserted into the database. |
168
|
|
|
|
|
|
|
Will default to the current time. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The JSON report also contains a C<created> field. This is the date/time |
171
|
|
|
|
|
|
|
that the report was created on the reporter's machine. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 report |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
The full JSON report. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
XXX: Describe the format a little and link to the main schema OpenAPI |
178
|
|
|
|
|
|
|
format on http://api.cpantesters.org |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
The serializer for this column will convert UTF-8 characters into their |
181
|
|
|
|
|
|
|
corresponding C<\u####> escape sequence, so this column is safe for |
182
|
|
|
|
|
|
|
tables with Latin1 encoding. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 METHODS |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 new |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Create a new object. This is called automatically by the ResultSet |
189
|
|
|
|
|
|
|
object and should not be called directly. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is overridden to provide sane defaults for the C<id> and C<created> |
192
|
|
|
|
|
|
|
fields. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
B<NOTE:> You should not supply a C<created> unless you are creating |
195
|
|
|
|
|
|
|
reports in the past. Reports created in the past will be hidden from |
196
|
|
|
|
|
|
|
many feeds, and may cause failures to not be reported to authors. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 upload |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
my $upload = $row->upload; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Get the associated L<CPAN::Testers::Schema::Result::Upload> object for |
203
|
|
|
|
|
|
|
the distribution tested by this test report. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 SEE ALSO |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L<DBIx::Class::Row>, L<CPAN::Testers::Schema> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 AUTHORS |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over 4 |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Oriol Soriano <oriolsoriano@gmail.com> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Doug Bell <preaction@cpan.org> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Oriol Soriano, Doug Bell. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
228
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |