File Coverage

blib/lib/CPAN/Testers/Schema/Result/Stats.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1 13     13   14555 use utf8;
  13         52  
  13         132  
2             package CPAN::Testers::Schema::Result::Stats;
3             our $VERSION = '0.024';
4             # ABSTRACT: The basic statistics information extracted from test reports
5              
6             #pod =head1 SYNOPSIS
7             #pod
8             #pod my $schema = CPAN::Testers::Schema->connect( $dsn, $user, $pass );
9             #pod
10             #pod # Retrieve a row
11             #pod my $row = $schema->resultset( 'Stats' )->first;
12             #pod # pass from doug@example.com (Doug Bell) using Perl 5.20.1 on darwin
13             #pod say sprintf "%s from %s using Perl %s on %s",
14             #pod $row->state,
15             #pod $row->tester,
16             #pod $row->perl,
17             #pod $row->osname;
18             #pod
19             #pod # Create a new row
20             #pod my %new_row_data = (
21             #pod state => 'fail',
22             #pod guid => '00000000-0000-0000-0000-000000000000',
23             #pod tester => 'doug@example.com (Doug Bell)',
24             #pod postdate => '201608',
25             #pod dist => 'My-Dist',
26             #pod version => '0.001',
27             #pod platform => 'darwin-2level',
28             #pod perl => '5.22.0',
29             #pod osname => 'darwin',
30             #pod osvers => '10.8.0',
31             #pod fulldate => '201608120401',
32             #pod type => 2,
33             #pod uploadid => 287102,
34             #pod );
35             #pod my $new_row = $schema->resultset( 'Stats' )->insert( \%new_row_data );
36             #pod
37             #pod =head1 DESCRIPTION
38             #pod
39             #pod This table (C<cpanstats> in the database) hold the basic, vital statistics
40             #pod extracted from test reports. This data is used to generate reports for the
41             #pod web application and web APIs.
42             #pod
43             #pod See C<ATTRIBUTES> below for the full list of attributes.
44             #pod
45             #pod This data is built from the Metabase by the L<CPAN::Testers::Data::Generator>.
46             #pod
47             #pod =head1 SEE ALSO
48             #pod
49             #pod L<DBIx::Class::Row>, L<CPAN::Testers::Schema>
50             #pod
51             #pod =cut
52              
53 13     13   956 use CPAN::Testers::Schema::Base 'Result';
  13         31  
  13         101  
54             table 'cpanstats';
55              
56             #pod =attr id
57             #pod
58             #pod The ID of the row. Auto-generated.
59             #pod
60             #pod =cut
61              
62             primary_column 'id', {
63             data_type => 'int',
64             extra => { unsigned => 1 },
65             is_auto_increment => 1,
66             is_nullable => 0,
67             };
68              
69             #pod =attr guid
70             #pod
71             #pod The UUID of this report from the Metabase, stored in standard hex string
72             #pod representation.
73             #pod
74             #pod =cut
75              
76             # Must be unique for foreign keys to work
77             column 'guid', {
78             data_type => 'char',
79             is_nullable => 0,
80             size => 36,
81             };
82             unique_constraint guid => [qw( guid )];
83              
84             #pod =attr state
85             #pod
86             #pod The state of the report. One of:
87             #pod
88             #pod =over 4
89             #pod
90             #pod =item C<pass>
91             #pod
92             #pod The tests passed and everything went well.
93             #pod
94             #pod =item C<fail>
95             #pod
96             #pod The tests ran but failed.
97             #pod
98             #pod =item C<na>
99             #pod
100             #pod This dist is incompatible with the tester's Perl or OS.
101             #pod
102             #pod =item C<unknown>
103             #pod
104             #pod The state could not be determined.
105             #pod
106             #pod =back
107             #pod
108             #pod C<invalid> reports, which are marked that way by dist authors when the
109             #pod problem is on the tester's machine, are handled by the L</type> field.
110             #pod
111             #pod =cut
112              
113             column 'state', {
114             data_type => 'enum',
115             extra => { list => ['pass', 'fail', 'unknown', 'na'] },
116             is_nullable => 0,
117             };
118              
119             #pod =attr postdate
120             #pod
121             #pod A truncated date, consisting only of the year and month in C<YYYYMM>
122             #pod format.
123             #pod
124             #pod =cut
125              
126             column 'postdate', {
127             data_type => 'mediumint',
128             extra => { unsigned => 1 },
129             is_nullable => 0,
130             };
131              
132             #pod =attr tester
133             #pod
134             #pod The e-mail address of the tester who sent this report, optionally with
135             #pod the tester's name as a comment (C<doug@example.com (Doug Bell)>).
136             #pod
137             #pod =cut
138              
139             column 'tester', {
140             data_type => 'varchar',
141             is_nullable => 0,
142             size => 255,
143             };
144              
145             #pod =attr dist
146             #pod
147             #pod The distribution that was tested.
148             #pod
149             #pod =cut
150              
151             column 'dist', {
152             data_type => 'varchar',
153             is_nullable => 0,
154             size => 255,
155             };
156              
157             #pod =attr version
158             #pod
159             #pod The version of the distribution.
160             #pod
161             #pod =cut
162              
163             column 'version', {
164             data_type => 'varchar',
165             is_nullable => 0,
166             size => 255,
167             };
168              
169             #pod =attr platform
170             #pod
171             #pod The Perl C<platform> string (from C<$Config{archname}>).
172             #pod
173             #pod =cut
174              
175             column 'platform', {
176             data_type => 'varchar',
177             is_nullable => 0,
178             size => 255,
179             };
180              
181             #pod =attr perl
182             #pod
183             #pod The version of Perl that was used to run the tests (from
184             #pod C<$Config{version}>).
185             #pod
186             #pod =cut
187              
188             column 'perl', {
189             data_type => 'varchar',
190             is_nullable => 0,
191             size => 255,
192             };
193              
194             #pod =attr osname
195             #pod
196             #pod The name of the operating system (from C<$Config{osname}>).
197             #pod
198             #pod =cut
199              
200             column 'osname', {
201             data_type => 'varchar',
202             is_nullable => 0,
203             size => 255,
204             };
205              
206             #pod =attr osvers
207             #pod
208             #pod The version of the operating system (from C<$Config{osvers}>).
209             #pod
210             #pod =cut
211              
212             column 'osvers', {
213             data_type => 'varchar',
214             is_nullable => 0,
215             size => 255,
216             };
217              
218             #pod =attr fulldate
219             #pod
220             #pod The full date of the report, with hours and minutes, in C<YYYYMMDDHHNN>
221             #pod format.
222             #pod
223             #pod =cut
224              
225             column 'fulldate', {
226             data_type => 'varchar',
227             is_nullable => 0,
228             size => 32,
229             };
230              
231             #pod =attr type
232             #pod
233             #pod A field that declares the status of this row. The only current
234             #pod possibilities are:
235             #pod
236             #pod =over 4
237             #pod
238             #pod =item 2 - This is a valid Perl 5 test report
239             #pod
240             #pod =item 3 - This report was marked invalid by a user
241             #pod
242             #pod =back
243             #pod
244             #pod =cut
245              
246             column 'type', {
247             data_type => 'tinyint',
248             extra => { unsigned => 1 },
249             is_nullable => 0,
250             };
251              
252             #pod =attr uploadid
253             #pod
254             #pod The ID of the upload that created this dist. Related to the C<uploadid>
255             #pod field in the C<uploads> table (see
256             #pod L<CPAN::Testers::Schema::Result::Uploads>).
257             #pod
258             #pod =cut
259              
260             column 'uploadid', {
261             data_type => 'int',
262             extra => { unsigned => 1 },
263             is_nullable => 0,
264             };
265              
266             #pod =method upload
267             #pod
268             #pod Get the related row in the `uploads` table. See L<CPAN::Testers::Schema::Result::Upload>.
269             #pod
270             #pod =cut
271              
272             belongs_to upload => 'CPAN::Testers::Schema::Result::Upload' => 'uploadid';
273              
274             #pod =method perl_version
275             #pod
276             #pod Get the related metadata about the Perl version this report is for. See
277             #pod L<CPAN::Testers::Schema::Result::PerlVersion>.
278             #pod
279             #pod =cut
280              
281             might_have perl_version => 'CPAN::Testers::Schema::Result::PerlVersion' =>
282             { 'foreign.version' => 'self.perl' };
283              
284             1;
285              
286             __END__
287              
288             =pod
289              
290             =head1 NAME
291              
292             CPAN::Testers::Schema::Result::Stats - The basic statistics information extracted from test reports
293              
294             =head1 VERSION
295              
296             version 0.024
297              
298             =head1 SYNOPSIS
299              
300             my $schema = CPAN::Testers::Schema->connect( $dsn, $user, $pass );
301              
302             # Retrieve a row
303             my $row = $schema->resultset( 'Stats' )->first;
304             # pass from doug@example.com (Doug Bell) using Perl 5.20.1 on darwin
305             say sprintf "%s from %s using Perl %s on %s",
306             $row->state,
307             $row->tester,
308             $row->perl,
309             $row->osname;
310              
311             # Create a new row
312             my %new_row_data = (
313             state => 'fail',
314             guid => '00000000-0000-0000-0000-000000000000',
315             tester => 'doug@example.com (Doug Bell)',
316             postdate => '201608',
317             dist => 'My-Dist',
318             version => '0.001',
319             platform => 'darwin-2level',
320             perl => '5.22.0',
321             osname => 'darwin',
322             osvers => '10.8.0',
323             fulldate => '201608120401',
324             type => 2,
325             uploadid => 287102,
326             );
327             my $new_row = $schema->resultset( 'Stats' )->insert( \%new_row_data );
328              
329             =head1 DESCRIPTION
330              
331             This table (C<cpanstats> in the database) hold the basic, vital statistics
332             extracted from test reports. This data is used to generate reports for the
333             web application and web APIs.
334              
335             See C<ATTRIBUTES> below for the full list of attributes.
336              
337             This data is built from the Metabase by the L<CPAN::Testers::Data::Generator>.
338              
339             =head1 ATTRIBUTES
340              
341             =head2 id
342              
343             The ID of the row. Auto-generated.
344              
345             =head2 guid
346              
347             The UUID of this report from the Metabase, stored in standard hex string
348             representation.
349              
350             =head2 state
351              
352             The state of the report. One of:
353              
354             =over 4
355              
356             =item C<pass>
357              
358             The tests passed and everything went well.
359              
360             =item C<fail>
361              
362             The tests ran but failed.
363              
364             =item C<na>
365              
366             This dist is incompatible with the tester's Perl or OS.
367              
368             =item C<unknown>
369              
370             The state could not be determined.
371              
372             =back
373              
374             C<invalid> reports, which are marked that way by dist authors when the
375             problem is on the tester's machine, are handled by the L</type> field.
376              
377             =head2 postdate
378              
379             A truncated date, consisting only of the year and month in C<YYYYMM>
380             format.
381              
382             =head2 tester
383              
384             The e-mail address of the tester who sent this report, optionally with
385             the tester's name as a comment (C<doug@example.com (Doug Bell)>).
386              
387             =head2 dist
388              
389             The distribution that was tested.
390              
391             =head2 version
392              
393             The version of the distribution.
394              
395             =head2 platform
396              
397             The Perl C<platform> string (from C<$Config{archname}>).
398              
399             =head2 perl
400              
401             The version of Perl that was used to run the tests (from
402             C<$Config{version}>).
403              
404             =head2 osname
405              
406             The name of the operating system (from C<$Config{osname}>).
407              
408             =head2 osvers
409              
410             The version of the operating system (from C<$Config{osvers}>).
411              
412             =head2 fulldate
413              
414             The full date of the report, with hours and minutes, in C<YYYYMMDDHHNN>
415             format.
416              
417             =head2 type
418              
419             A field that declares the status of this row. The only current
420             possibilities are:
421              
422             =over 4
423              
424             =item 2 - This is a valid Perl 5 test report
425              
426             =item 3 - This report was marked invalid by a user
427              
428             =back
429              
430             =head2 uploadid
431              
432             The ID of the upload that created this dist. Related to the C<uploadid>
433             field in the C<uploads> table (see
434             L<CPAN::Testers::Schema::Result::Uploads>).
435              
436             =head1 METHODS
437              
438             =head2 upload
439              
440             Get the related row in the `uploads` table. See L<CPAN::Testers::Schema::Result::Upload>.
441              
442             =head2 perl_version
443              
444             Get the related metadata about the Perl version this report is for. See
445             L<CPAN::Testers::Schema::Result::PerlVersion>.
446              
447             =head1 SEE ALSO
448              
449             L<DBIx::Class::Row>, L<CPAN::Testers::Schema>
450              
451             =head1 AUTHORS
452              
453             =over 4
454              
455             =item *
456              
457             Oriol Soriano <oriolsoriano@gmail.com>
458              
459             =item *
460              
461             Doug Bell <preaction@cpan.org>
462              
463             =back
464              
465             =head1 COPYRIGHT AND LICENSE
466              
467             This software is copyright (c) 2018 by Oriol Soriano, Doug Bell.
468              
469             This is free software; you can redistribute it and/or modify it under
470             the same terms as the Perl 5 programming language system itself.
471              
472             =cut