blib/lib/CPAN/Testers/Schema/ResultSet/Upload.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 100% 28 / 28 SCAR 6.9
CC
2
Cov
100%
recent
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/CPAN/Testers/Schema/ResultSet/Release.pm ↑ Summary /dev/null »
1 15 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package CPAN::Testers::Schema::ResultSet::Upload;
3 15 our $VERSION = '0.025';
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 15 ▶use CPAN::Testers::Schema::Base 'ResultSet';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 15 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶sub by_dist( $self, $dist ) {
Subroutine by_dist: called CC=1 SCAR=0.0
Pod documented
40 2 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 ▶sub by_author( $self, $author ) {
Subroutine by_author: called CC=1 SCAR=0.0
Pod documented
53 2 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 ▶sub since( $self, $date ) {
Subroutine since: called CC=1 SCAR=0.0
Pod documented
66 3 my $dt = DateTime::Format::ISO8601->parse_datetime( $date );
67 3 return $self->search( { released => { '>=' => $dt->epoch } } );
68 }
69  
70 #pod =method recent
71 #pod
72 #pod # 20 most recent
73 #pod $rs = $rs->recent( 20 );
74 #pod
75 #pod # Just the most recent
76 #pod $rs = $rs->recent( 1 );
77 #pod
78 #pod Return the most-recently released distributions sorted by their release
79 #pod date/time, descending. Defaults to returning up to 20 results.
80 #pod
81 #pod =cut
82  
83 2 ▶sub recent( $self, $count = 20 ) {
Subroutine recent: called CC=2 SCAR=6.9
Pod documented
84 2 return $self->search( { }, {
85 order_by => { -desc => 'released' },
86 rows => $count,
87 page => 1,
88 } );
89 }
90  
91 15 1;
92  
93 __END__
94  
95 =pod
96  
97 =head1 NAME
98  
99 CPAN::Testers::Schema::ResultSet::Upload - Query the CPAN uploads data
100  
101 =head1 VERSION
102  
103 version 0.025
104  
105 =head1 SYNOPSIS
106  
107 my $rs = $schema->resultset( 'Upload' );
108 $rs->by_dist( 'My-Dist' );
109 $rs->by_author( 'PREACTION' );
110 $rs->since( '2016-01-01T00:00:00' );
111  
112 =head1 DESCRIPTION
113  
114 This object helps to query the CPAN uploads table. This table tracks
115 uploads to CPAN by distribution, version, and author, and also flags
116 distributions that have been deleted from CPAN (and are thus only
117 available on BackPAN).
118  
119 =head1 METHODS
120  
121 =head2 by_dist
122  
123 $rs = $rs->by_dist( 'My-Dist' );
124  
125 Add a dist constraint to the query, replacing any previous dist
126 constraints.
127  
128 =head2 by_author
129  
130 $rs = $rs->by_author( 'PREACTION' );
131  
132 Add an author constraint to the query, replacing any previous author
133 constraints.
134  
135 =head2 since
136  
137 $rs = $rs->since( '2016-01-01T00:00:00' );
138  
139 Restrict results to only those that have been updated since the given
140 ISO8601 date.
141  
142 =head2 recent
143  
144 # 20 most recent
145 $rs = $rs->recent( 20 );
146  
147 # Just the most recent
148 $rs = $rs->recent( 1 );
149  
150 Return the most-recently released distributions sorted by their release
151 date/time, descending. Defaults to returning up to 20 results.
152  
153 =head1 SEE ALSO
154  
155 L<CPAN::Testers::Schema::Result::Upload>, L<DBIx::Class::ResultSet>,
156 L<CPAN::Testers::Schema>
157  
158 =head1 AUTHORS
159  
160 =over 4
161  
162 =item *
163  
164 Oriol Soriano <oriolsoriano@gmail.com>
165  
166 =item *
167  
168 Doug Bell <preaction@cpan.org>
169  
170 =back
171  
172 =head1 COPYRIGHT AND LICENSE
173  
174 This software is copyright (c) 2018 by Oriol Soriano, Doug Bell.
175  
176 This is free software; you can redistribute it and/or modify it under
177 the same terms as the Perl 5 programming language system itself.
178  
179 =cut
« blib/lib/CPAN/Testers/Schema/ResultSet/Release.pm ↑ Summary /dev/null »