File Coverage

blib/lib/CPAN/Testers/Schema/ResultSet/Upload.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1 13     13   14202 use utf8;
  13         82  
  13         75  
2             package CPAN::Testers::Schema::ResultSet::Upload;
3             our $VERSION = '0.024';
4             # ABSTRACT: Query the CPAN uploads data
5              
6             #pod =head1 SYNOPSIS
7             #pod
8             #pod my $rs = $schema->resultset( 'Upload' );
9             #pod $rs->by_dist( 'My-Dist' );
10             #pod $rs->by_author( 'PREACTION' );
11             #pod $rs->since( '2016-01-01T00:00:00' );
12             #pod
13             #pod =head1 DESCRIPTION
14             #pod
15             #pod This object helps to query the CPAN uploads table. This table tracks
16             #pod uploads to CPAN by distribution, version, and author, and also flags
17             #pod distributions that have been deleted from CPAN (and are thus only
18             #pod available on BackPAN).
19             #pod
20             #pod =head1 SEE ALSO
21             #pod
22             #pod L<CPAN::Testers::Schema::Result::Upload>, L<DBIx::Class::ResultSet>,
23             #pod L<CPAN::Testers::Schema>
24             #pod
25             #pod =cut
26              
27 13     13   853 use CPAN::Testers::Schema::Base 'ResultSet';
  13         66  
  13         119  
28 13     13   481 use DateTime::Format::ISO8601;
  13         34  
  13         2612  
29              
30             #pod =method by_dist
31             #pod
32             #pod $rs = $rs->by_dist( 'My-Dist' );
33             #pod
34             #pod Add a dist constraint to the query, replacing any previous dist
35             #pod constraints.
36             #pod
37             #pod =cut
38              
39 2     2 1 803828 sub by_dist( $self, $dist ) {
  2         5  
  2         6  
  2         4  
40 2         13 return $self->search( { 'me.dist' => $dist } );
41             }
42              
43             #pod =method by_author
44             #pod
45             #pod $rs = $rs->by_author( 'PREACTION' );
46             #pod
47             #pod Add an author constraint to the query, replacing any previous author
48             #pod constraints.
49             #pod
50             #pod =cut
51              
52 2     2 1 14831 sub by_author( $self, $author ) {
  2         6  
  2         5  
  2         5  
53 2         9 return $self->search( { 'me.author' => $author } );
54             }
55              
56             #pod =method since
57             #pod
58             #pod $rs = $rs->since( '2016-01-01T00:00:00' );
59             #pod
60             #pod Restrict results to only those that have been updated since the given
61             #pod ISO8601 date.
62             #pod
63             #pod =cut
64              
65 3     3 1 9597 sub since( $self, $date ) {
  3         6  
  3         6  
  3         5  
66 3         22 my $dt = DateTime::Format::ISO8601->parse_datetime( $date );
67 3         1944 return $self->search( { released => { '>=' => $dt->epoch } } );
68             }
69              
70             1;
71              
72             __END__
73              
74             =pod
75              
76             =head1 NAME
77              
78             CPAN::Testers::Schema::ResultSet::Upload - Query the CPAN uploads data
79              
80             =head1 VERSION
81              
82             version 0.024
83              
84             =head1 SYNOPSIS
85              
86             my $rs = $schema->resultset( 'Upload' );
87             $rs->by_dist( 'My-Dist' );
88             $rs->by_author( 'PREACTION' );
89             $rs->since( '2016-01-01T00:00:00' );
90              
91             =head1 DESCRIPTION
92              
93             This object helps to query the CPAN uploads table. This table tracks
94             uploads to CPAN by distribution, version, and author, and also flags
95             distributions that have been deleted from CPAN (and are thus only
96             available on BackPAN).
97              
98             =head1 METHODS
99              
100             =head2 by_dist
101              
102             $rs = $rs->by_dist( 'My-Dist' );
103              
104             Add a dist constraint to the query, replacing any previous dist
105             constraints.
106              
107             =head2 by_author
108              
109             $rs = $rs->by_author( 'PREACTION' );
110              
111             Add an author constraint to the query, replacing any previous author
112             constraints.
113              
114             =head2 since
115              
116             $rs = $rs->since( '2016-01-01T00:00:00' );
117              
118             Restrict results to only those that have been updated since the given
119             ISO8601 date.
120              
121             =head1 SEE ALSO
122              
123             L<CPAN::Testers::Schema::Result::Upload>, L<DBIx::Class::ResultSet>,
124             L<CPAN::Testers::Schema>
125              
126             =head1 AUTHORS
127              
128             =over 4
129              
130             =item *
131              
132             Oriol Soriano <oriolsoriano@gmail.com>
133              
134             =item *
135              
136             Doug Bell <preaction@cpan.org>
137              
138             =back
139              
140             =head1 COPYRIGHT AND LICENSE
141              
142             This software is copyright (c) 2018 by Oriol Soriano, Doug Bell.
143              
144             This is free software; you can redistribute it and/or modify it under
145             the same terms as the Perl 5 programming language system itself.
146              
147             =cut