File Coverage

blib/lib/CPAN/Testers/Schema/ResultSet/Release.pm
Criterion Covered Total %
statement 34 34 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 4 4 100.0
total 46 46 100.0


line stmt bran cond sub pod time code
1 13     13   15684 use utf8;
  13         35  
  13         92  
2             package CPAN::Testers::Schema::ResultSet::Release;
3             our $VERSION = '0.024';
4             # ABSTRACT: Query the per-release summary testers data
5              
6             #pod =head1 SYNOPSIS
7             #pod
8             #pod my $rs = $schema->resultset( 'Release' );
9             #pod $rs->by_dist( 'My-Dist', '0.001' );
10             #pod $rs->by_author( 'PREACTION' );
11             #pod $rs->since( '2016-01-01T00:00:00' );
12             #pod $rs->maturity( 'stable' );
13             #pod
14             #pod =head1 DESCRIPTION
15             #pod
16             #pod This object helps to query the per-release test report summaries. These
17             #pod summaries say how many pass, fail, NA, and unknown results a single
18             #pod version of a distribution has.
19             #pod
20             #pod =head1 SEE ALSO
21             #pod
22             #pod L<DBIx::Class::ResultSet>, L<CPAN::Testers::Schema>
23             #pod
24             #pod =cut
25              
26 13     13   879 use CPAN::Testers::Schema::Base 'ResultSet';
  13         35  
  13         129  
27              
28             #pod =method by_dist
29             #pod
30             #pod $rs = $rs->by_dist( 'My-Dist' );
31             #pod $rs = $rs->by_dist( 'My-Dist', '0.001' );
32             #pod
33             #pod Add a dist constraint to the query (with optional version), replacing
34             #pod any previous dist constraints.
35             #pod
36             #pod =cut
37              
38 4     4 1 42625 sub by_dist( $self, $dist, $version = undef ) {
  4         10  
  4         5  
  4         9  
  4         5  
39 4         13 my %search = ( 'me.dist' => $dist );
40 4 100       14 if ( $version ) {
41 1         4 $search{ 'me.version' } = $version;
42             }
43 4         13 return $self->search( \%search );
44             }
45              
46             #pod =method by_author
47             #pod
48             #pod $rs = $rs->by_author( 'PREACTION' );
49             #pod
50             #pod Add an author constraint to the query, replacing any previous author
51             #pod constraints.
52             #pod
53             #pod =cut
54              
55 3     3 1 38436 sub by_author( $self, $author ) {
  3         8  
  3         6  
  3         8  
56 3         20 return $self->search( { 'upload.author' => $author }, { join => 'upload' } );
57             }
58              
59             #pod =method since
60             #pod
61             #pod $rs = $rs->since( '2016-01-01T00:00:00' );
62             #pod
63             #pod Restrict results to only those that have been updated since the given
64             #pod ISO8601 date.
65             #pod
66             #pod =cut
67              
68 4     4 1 804742 sub since( $self, $date ) {
  4         10  
  4         8  
  4         8  
69 4         28 my $fulldate = $date =~ s/[-:T]//gr;
70 4         13 $fulldate = substr $fulldate, 0, 12; # 12 digits makes YYYYMMDDHHNN
71 4         33 return $self->search( { 'report.fulldate' => { '>=', $fulldate } }, { join => 'report' } );
72             }
73              
74             #pod =method maturity
75             #pod
76             #pod $rs = $rs->maturity( 'stable' );
77             #pod
78             #pod Restrict results to only those dists that are stable. Also supported:
79             #pod 'dev' to restrict to only development dists.
80             #pod
81             #pod =cut
82              
83 5     5 1 25970 sub maturity( $self, $maturity ) {
  5         11  
  5         10  
  5         9  
84 5         20 my %map = ( 'stable' => 1, 'dev' => 2 );
85 5         12 $maturity = $map{ $maturity };
86 5         34 return $self->search( { 'me.distmat' => $maturity } );
87             }
88              
89             1;
90              
91             __END__
92              
93             =pod
94              
95             =head1 NAME
96              
97             CPAN::Testers::Schema::ResultSet::Release - Query the per-release summary testers data
98              
99             =head1 VERSION
100              
101             version 0.024
102              
103             =head1 SYNOPSIS
104              
105             my $rs = $schema->resultset( 'Release' );
106             $rs->by_dist( 'My-Dist', '0.001' );
107             $rs->by_author( 'PREACTION' );
108             $rs->since( '2016-01-01T00:00:00' );
109             $rs->maturity( 'stable' );
110              
111             =head1 DESCRIPTION
112              
113             This object helps to query the per-release test report summaries. These
114             summaries say how many pass, fail, NA, and unknown results a single
115             version of a distribution has.
116              
117             =head1 METHODS
118              
119             =head2 by_dist
120              
121             $rs = $rs->by_dist( 'My-Dist' );
122             $rs = $rs->by_dist( 'My-Dist', '0.001' );
123              
124             Add a dist constraint to the query (with optional version), replacing
125             any previous dist constraints.
126              
127             =head2 by_author
128              
129             $rs = $rs->by_author( 'PREACTION' );
130              
131             Add an author constraint to the query, replacing any previous author
132             constraints.
133              
134             =head2 since
135              
136             $rs = $rs->since( '2016-01-01T00:00:00' );
137              
138             Restrict results to only those that have been updated since the given
139             ISO8601 date.
140              
141             =head2 maturity
142              
143             $rs = $rs->maturity( 'stable' );
144              
145             Restrict results to only those dists that are stable. Also supported:
146             'dev' to restrict to only development dists.
147              
148             =head1 SEE ALSO
149              
150             L<DBIx::Class::ResultSet>, L<CPAN::Testers::Schema>
151              
152             =head1 AUTHORS
153              
154             =over 4
155              
156             =item *
157              
158             Oriol Soriano <oriolsoriano@gmail.com>
159              
160             =item *
161              
162             Doug Bell <preaction@cpan.org>
163              
164             =back
165              
166             =head1 COPYRIGHT AND LICENSE
167              
168             This software is copyright (c) 2018 by Oriol Soriano, Doug Bell.
169              
170             This is free software; you can redistribute it and/or modify it under
171             the same terms as the Perl 5 programming language system itself.
172              
173             =cut