line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ORDB::CPANRT; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# See CPANRT.pod for docs |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
960
|
use 5.008005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
16
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
5442
|
use DateTime 0.55 (); |
|
1
|
|
|
|
|
274146
|
|
|
1
|
|
|
|
|
52
|
|
9
|
1
|
|
|
1
|
|
12
|
use Params::Util 1.00 (); |
|
1
|
|
|
|
|
23
|
|
|
1
|
|
|
|
|
20
|
|
10
|
1
|
|
|
1
|
|
1999
|
use ORLite::Mirror 1.20 (); |
|
1
|
|
|
|
|
249315
|
|
|
1
|
|
|
|
|
275
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
13
|
|
|
|
|
|
|
our @LOCATION = ( |
14
|
|
|
|
|
|
|
locale => 'C', |
15
|
|
|
|
|
|
|
time_zone => 'UTC', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
0
|
|
|
0
|
|
|
my $class = shift; |
20
|
0
|
|
0
|
|
|
|
my $param = Params::Util::_HASH(shift) || {}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Pass through any params from above |
23
|
0
|
|
0
|
|
|
|
$param->{url} ||= 'http://rt.cpan.org/NoAuth/cpan/rtcpan.sqlite.gz'; |
24
|
0
|
|
0
|
|
|
|
$param->{maxage} ||= 24 * 60 * 60; # One day |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Prevent double-initialisation |
27
|
0
|
0
|
|
|
|
|
$class->can('orlite') or |
28
|
|
|
|
|
|
|
ORLite::Mirror->import($param); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub latest { |
34
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Find the most recent record |
37
|
0
|
|
|
|
|
|
my @latest = ORDB::CPANRT::Ticket->select( |
38
|
|
|
|
|
|
|
'ORDER BY updated DESC LIMIT 1', |
39
|
|
|
|
|
|
|
); |
40
|
0
|
0
|
|
|
|
|
unless ( @latest == 1 ) { |
41
|
0
|
|
|
|
|
|
die "Unexpected number of uploads"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$latest[0]->updated; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub latest_datetime { |
48
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
49
|
0
|
|
|
|
|
|
my @latest = split /\D+/, $class->latest; |
50
|
0
|
|
|
|
|
|
return DateTime->new( |
51
|
|
|
|
|
|
|
year => $latest[0], |
52
|
|
|
|
|
|
|
month => $latest[1], |
53
|
|
|
|
|
|
|
day => $latest[2], |
54
|
|
|
|
|
|
|
@LOCATION, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub age { |
59
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
60
|
0
|
|
|
|
|
|
my $latest = $class->latest_datetime; |
61
|
0
|
|
|
|
|
|
my $today = DateTime->today( @LOCATION ); |
62
|
0
|
|
|
|
|
|
my $duration = $today - $latest; |
63
|
0
|
|
|
|
|
|
return $duration->in_units('days'); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |