| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Labyrinth::Plugin::CPAN::Builder; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
42649
|
use strict; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
121
|
|
|
4
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
127
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
22
|
use vars qw($VERSION); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
207
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '3.60'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Labyrinth::Plugin::CPAN::Builder - Plugin to build the static files that drive the dynamic site. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
16
|
|
|
|
|
|
|
# Libraries |
|
17
|
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
22
|
use base qw(Labyrinth::Plugin::Base); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
652
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
858567
|
use Labyrinth::Audit; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
578
|
|
|
21
|
4
|
|
|
4
|
|
91
|
use Labyrinth::DTUtils; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
284
|
|
|
22
|
4
|
|
|
4
|
|
27
|
use Labyrinth::MLUtils; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
483
|
|
|
23
|
4
|
|
|
4
|
|
26
|
use Labyrinth::Mailer; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
202
|
|
|
24
|
4
|
|
|
4
|
|
46
|
use Labyrinth::Session; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
247
|
|
|
25
|
4
|
|
|
4
|
|
30
|
use Labyrinth::Support; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
490
|
|
|
26
|
4
|
|
|
4
|
|
27
|
use Labyrinth::Variables; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
569
|
|
|
27
|
4
|
|
|
4
|
|
29
|
use Labyrinth::Writer; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
245
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
|
492
|
use Labyrinth::Plugin::CPAN; |
|
|
4
|
|
|
|
|
11615
|
|
|
|
4
|
|
|
|
|
37
|
|
|
30
|
4
|
|
|
4
|
|
2241
|
use Labyrinth::Plugin::Articles::Site; |
|
|
4
|
|
|
|
|
67226
|
|
|
|
4
|
|
|
|
|
144
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
|
|
4
|
|
41
|
use Clone qw(clone); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
170
|
|
|
33
|
4
|
|
|
4
|
|
24
|
use Cwd; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
239
|
|
|
34
|
4
|
|
|
4
|
|
26
|
use File::Path; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
178
|
|
|
35
|
4
|
|
|
4
|
|
25
|
use File::Slurp; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
248
|
|
|
36
|
4
|
|
|
4
|
|
588
|
use JSON::XS; |
|
|
4
|
|
|
|
|
2695
|
|
|
|
4
|
|
|
|
|
204
|
|
|
37
|
|
|
|
|
|
|
#use Sort::Versions; |
|
38
|
4
|
|
|
4
|
|
30
|
use Time::Local; |
|
|
4
|
|
|
|
|
20
|
|
|
|
4
|
|
|
|
|
195
|
|
|
39
|
4
|
|
|
4
|
|
37
|
use Try::Tiny; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
217
|
|
|
40
|
4
|
|
|
4
|
|
1566
|
use XML::RSS; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#use YAML::XS; |
|
42
|
|
|
|
|
|
|
use version; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#use Devel::Size qw(total_size); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
47
|
|
|
|
|
|
|
# Variables |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $RECENT = 200; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
52
|
|
|
|
|
|
|
# Public Interface Functions |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 Public Interface Methods |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over 4 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item BasePages |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Regenerates all site pages. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item Process |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Simple control process. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item IndexPages |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Rebuilds the index pages for each author and distribution letter directory. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item RemovePages |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Master controller for removing reports from author and distribution pages. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item RemoveAuthorPages |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Routine for removing reports from author pages. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item RemoveDistroPages |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Routine for removing reports from distribution pages. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item AuthorPages |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Rebuilds a named author page. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item DistroPages |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Rebuilds a named distribution page. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item StatsPages |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Rebuilds the stats pages for pass matrix. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item RecentPage |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Regenerates the recent page, and associated files. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub BasePages { |
|
105
|
|
|
|
|
|
|
my $cache = sprintf "%s/static", $settings{webdir}; |
|
106
|
|
|
|
|
|
|
mkpath($cache); |
|
107
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
108
|
|
|
|
|
|
|
$tvars{static} = 1; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$tvars{content} = "content/welcome.html"; |
|
111
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%tvars ); |
|
112
|
|
|
|
|
|
|
overwrite_file( $cache . '/index.html', $text ); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $site = Labyrinth::Plugin::Articles::Site->new(); |
|
115
|
|
|
|
|
|
|
$tvars{content} = "articles/arts-item.html"; |
|
116
|
|
|
|
|
|
|
for my $page (qw(help about)) { |
|
117
|
|
|
|
|
|
|
$cgiparams{'name'} = $page; |
|
118
|
|
|
|
|
|
|
$site->Item(); |
|
119
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-static.html', \%tvars ); |
|
120
|
|
|
|
|
|
|
overwrite_file( "$cache/page/$page.html", $text ); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub Process { |
|
125
|
|
|
|
|
|
|
my ($self,$progress,$type) = @_; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# check whether we are running split or combined queries |
|
128
|
|
|
|
|
|
|
my $types = $type ? "'$type'" : "'author','distro'"; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $cpan = Labyrinth::Plugin::CPAN->new(); |
|
131
|
|
|
|
|
|
|
$cpan->Configure(); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $olderhit = 0; |
|
134
|
|
|
|
|
|
|
my $quickhit = 1; |
|
135
|
|
|
|
|
|
|
while(1) { |
|
136
|
|
|
|
|
|
|
my $cnt = IndexPages($cpan,$dbi,$progress,$type); |
|
137
|
|
|
|
|
|
|
$cnt += RemovePages($cpan,$dbi,$progress,$type); |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# shouldn't really hard code these :) |
|
140
|
|
|
|
|
|
|
my ($query,$loop,$limit) = ('GetRequests',10,10); |
|
141
|
|
|
|
|
|
|
($query,$loop,$limit) = ('GetOlderRequests',1,100) if($quickhit == 1); |
|
142
|
|
|
|
|
|
|
($query,$loop,$limit) = ('GetSmallRequests',2,10) if($quickhit == 3); |
|
143
|
|
|
|
|
|
|
($query,$loop,$limit) = ('GetLargeRequests',2,25) if($quickhit == 5); # typically these are long running author searches |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my %names; |
|
146
|
|
|
|
|
|
|
for(1..$loop) { |
|
147
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash',$query,{types => $types, limit => $limit}); |
|
148
|
|
|
|
|
|
|
last unless(@rows); |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
for my $row (@rows) { |
|
151
|
|
|
|
|
|
|
next unless(defined $row->{type}); |
|
152
|
|
|
|
|
|
|
next if($names{$row->{type}} && $names{$row->{type}}{$row->{name}}); |
|
153
|
|
|
|
|
|
|
if(defined $progress) { |
|
154
|
|
|
|
|
|
|
$progress->( ".. processing $row->{type} $row->{name} => $row->{count} $row->{total}" ); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
if($row->{type} eq 'author') { AuthorPages($cpan,$dbi,$row->{name},$progress) } |
|
157
|
|
|
|
|
|
|
else { DistroPages($cpan,$dbi,$row->{name},$progress) } |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$names{$row->{type}}{$row->{name}} = 1; # prevent repeating the same update too quickly. |
|
160
|
|
|
|
|
|
|
$cnt++; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $req = _request_count($dbi); |
|
165
|
|
|
|
|
|
|
$progress->( "Processed $cnt pages, $req requests remaining." ) if(defined $progress); |
|
166
|
|
|
|
|
|
|
#sleep(300) if($cnt == 0 || $req == 0); |
|
167
|
|
|
|
|
|
|
last if($cnt == 0 || $req == 0); |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $age = _request_oldest($dbi); |
|
170
|
|
|
|
|
|
|
my @row = $dbi->GetQuery('hash','GetLargeRequests',{types => $types, limit => 1}); |
|
171
|
|
|
|
|
|
|
my $sum = $row[0]->{total}; |
|
172
|
|
|
|
|
|
|
my $num = $row[0]->{count}; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$quickhit = |
|
175
|
|
|
|
|
|
|
$sum > $settings{buildlevel4} # very high sum of requests for one request type |
|
176
|
|
|
|
|
|
|
? 5 |
|
177
|
|
|
|
|
|
|
: $num > $settings{buildlevel5} # very high num of requests for one request type |
|
178
|
|
|
|
|
|
|
? 5 |
|
179
|
|
|
|
|
|
|
: $age > $settings{agelimit1} # requests older than x days take priority |
|
180
|
|
|
|
|
|
|
? 1 |
|
181
|
|
|
|
|
|
|
: $req < $settings{buildlevel1} # low amount of requests |
|
182
|
|
|
|
|
|
|
? 1 |
|
183
|
|
|
|
|
|
|
: $req < $settings{buildlevel2} # medium level of requests |
|
184
|
|
|
|
|
|
|
? ++$quickhit % 2 |
|
185
|
|
|
|
|
|
|
: $req < $settings{buildlevel3} # high level of requests |
|
186
|
|
|
|
|
|
|
? ++$quickhit % 4 |
|
187
|
|
|
|
|
|
|
: $age > $settings{agelimit2} # older than x days |
|
188
|
|
|
|
|
|
|
? 1 |
|
189
|
|
|
|
|
|
|
: ++$quickhit % 6; # very high level of requests |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub IndexPages { |
|
194
|
|
|
|
|
|
|
my ($cpan,$dbi,$progress,$type) = @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# check whether we are running split or combined queries |
|
197
|
|
|
|
|
|
|
my $types = "'ixauth','ixdist'"; |
|
198
|
|
|
|
|
|
|
$types = "'ixauth'" if($type && $type eq 'author'); |
|
199
|
|
|
|
|
|
|
$types = "'ixdist'" if($type && $type eq 'distro'); |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my @index = $dbi->GetQuery('hash','GetIndexRequests',{types => $types}); |
|
202
|
|
|
|
|
|
|
for my $index (@index) { |
|
203
|
|
|
|
|
|
|
my ($type,@list); |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$progress->( ".. processing $index->{type} $index->{name}" ) if(defined $progress); |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
if($index->{type} eq 'ixauth') { |
|
208
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash','GetAuthors',"$index->{name}%"); |
|
209
|
|
|
|
|
|
|
@list = map {$_->{author}} @rows; |
|
210
|
|
|
|
|
|
|
$type = 'author'; |
|
211
|
|
|
|
|
|
|
} else { |
|
212
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash','GetDistros',"$index->{name}%"); |
|
213
|
|
|
|
|
|
|
@list = map {$_->{dist}} @rows; |
|
214
|
|
|
|
|
|
|
$type = 'distro'; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/%s/%s", $settings{webdir}, $type, substr($index->{name},0,1); |
|
218
|
|
|
|
|
|
|
mkpath($cache); |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$tvars{letter} = $index->{name}; |
|
221
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
222
|
|
|
|
|
|
|
$tvars{content} = "cpan/$type-list.html"; |
|
223
|
|
|
|
|
|
|
$tvars{list} = \@list if(@list); |
|
224
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%tvars ); |
|
225
|
|
|
|
|
|
|
overwrite_file( $cache . '/index.html', $text ); |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
if($type eq 'distro') { |
|
228
|
|
|
|
|
|
|
$cache = sprintf "%s/stats/%s/%s", $settings{webdir}, $type, substr($index->{name},0,1); |
|
229
|
|
|
|
|
|
|
mkpath($cache); |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
my $destfile = "$cache/index.html"; |
|
232
|
|
|
|
|
|
|
#$progress->( ".. processing $index->{type} $index->{name} - $destfile" ) if(defined $progress); |
|
233
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-distro-index.html'; |
|
234
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
235
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
|
236
|
|
|
|
|
|
|
overwrite_file( $cache . '/index.html', $text ); |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# remove requests |
|
240
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => '0'},$index->{type},$index->{name}); |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
return scalar(@index); |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub RemovePages { |
|
247
|
|
|
|
|
|
|
my ($cpan,$dbi,$progress,$type) = @_; |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# check whether we are running split or combined queries |
|
250
|
|
|
|
|
|
|
my $types = "'rmauth','rmdist'"; |
|
251
|
|
|
|
|
|
|
$types = "'rmauth'" if($type && $type eq 'author'); |
|
252
|
|
|
|
|
|
|
$types = "'rmdist'" if($type && $type eq 'distro'); |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash','GetRequests',{types => $types, limit => 20}); |
|
255
|
|
|
|
|
|
|
return 0 unless(@rows); |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
my @index = $dbi->GetQuery('hash','GetIndexRequests',{types => $types}); |
|
258
|
|
|
|
|
|
|
for my $index (@index) { |
|
259
|
|
|
|
|
|
|
my ($type,@list); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
$progress->( ".. processing $index->{type} $index->{name}" ) if(defined $progress); |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
if($index->{type} eq 'rmauth') { |
|
264
|
|
|
|
|
|
|
# 2016-04-21 = Barbie - temporarily suspended line below to allow author pages to generate |
|
265
|
|
|
|
|
|
|
# seems to be a bug picking up UUID for PSIXDISTS :( |
|
266
|
|
|
|
|
|
|
RemoveAuthorPages($cpan,$dbi,$progress,$index->{name}); |
|
267
|
|
|
|
|
|
|
} else { |
|
268
|
|
|
|
|
|
|
RemoveDistroPages($cpan,$dbi,$progress,$index->{name}); |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# note $name is NOT the author name, but the dist name! need to get the reports to track version and then author |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub RemoveAuthorPages { |
|
276
|
|
|
|
|
|
|
my ($cpan,$dbi,$progress,$name) = @_; |
|
277
|
|
|
|
|
|
|
my (%remove,%author,@reports); |
|
278
|
|
|
|
|
|
|
my $fail = 0; |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# get ids from the page requests |
|
281
|
|
|
|
|
|
|
my @requests = $dbi->GetQuery('hash','GetRequestIDs',{names => $name},'rmauth'); |
|
282
|
|
|
|
|
|
|
my %requests = map { $_->{id} => 1 } grep { $_->{id} } @requests; |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
return unless(keys %requests); |
|
285
|
|
|
|
|
|
|
push my @ids, keys %requests; |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetReportsByIDs',{ids=>join(',',@ids)}); |
|
288
|
|
|
|
|
|
|
while(my $row = $next->()) { |
|
289
|
|
|
|
|
|
|
my @latest = $dbi->GetQuery('hash','CheckLatest',$row->{dist},$row->{version}); |
|
290
|
|
|
|
|
|
|
next unless(@latest); |
|
291
|
|
|
|
|
|
|
$author{$latest[0]->{author}}++; |
|
292
|
|
|
|
|
|
|
$remove{$row->{dist}}{uc $row->{state}}++; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
for my $author (keys %author) { |
|
296
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/author/%s", $settings{webdir}, substr($author,0,1); |
|
297
|
|
|
|
|
|
|
my $destfile = "$cache/$author.json"; |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
try { |
|
300
|
|
|
|
|
|
|
# load JSON, if we have one |
|
301
|
|
|
|
|
|
|
if(-f $destfile) { |
|
302
|
|
|
|
|
|
|
$progress->( ".. processing rmauth $author $name (cleaning JSON file)" ) if(defined $progress); |
|
303
|
|
|
|
|
|
|
my $data = read_file($destfile); |
|
304
|
|
|
|
|
|
|
$progress->( ".. processing rmauth $author $name (read JSON file)" ) if(defined $progress); |
|
305
|
|
|
|
|
|
|
my $store; |
|
306
|
|
|
|
|
|
|
eval { $store = decode_json($data) }; |
|
307
|
|
|
|
|
|
|
$progress->( ".. processing rmauth $author $name (decoded JSON data)" ) if(defined $progress); |
|
308
|
|
|
|
|
|
|
if(!$@ && $store) { |
|
309
|
|
|
|
|
|
|
for my $row (@$store) { |
|
310
|
|
|
|
|
|
|
next if($requests{$row->{id}}); # filter out requests |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
push @reports, $row; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
overwrite_file( $destfile, _make_json( \@reports ) ); |
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
# clean the summary, if we have one |
|
319
|
|
|
|
|
|
|
my @summary = $dbi->GetQuery('hash','GetAuthorSummary',$author); |
|
320
|
|
|
|
|
|
|
if(@summary) { |
|
321
|
|
|
|
|
|
|
$progress->( ".. processing rmauth $author $name (cleaning summary) " . scalar(@summary) . ' ' . ($summary[0] && $summary[0]->{dataset} ? 'true' : 'false') ) if(defined $progress); |
|
322
|
|
|
|
|
|
|
my $dataset = decode_json($summary[0]->{dataset}); |
|
323
|
|
|
|
|
|
|
$progress->( ".. processing rmauth $author $name (decoded JSON summary)" ) if(defined $progress); |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
for my $data ( @{ $dataset->{distributions} } ) { |
|
326
|
|
|
|
|
|
|
my $dist = $data->{dist}; |
|
327
|
|
|
|
|
|
|
my $summ = $data->{summary}; |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
next unless($remove{$dist}); |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
for my $state (keys %{ $remove{$dist} }) { |
|
332
|
|
|
|
|
|
|
$summ->{ $state } -= $remove{$dist}{$state}; |
|
333
|
|
|
|
|
|
|
$summ->{ 'ALL' } -= $remove{$dist}{$state}; |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
$dbi->DoQuery('UpdateAuthorSummary',$summary[0]->{lastid},encode_json($dataset),$author); |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# push in author queue to rebuild pages |
|
341
|
|
|
|
|
|
|
$dbi->DoQuery('PushAuthor',$author); |
|
342
|
|
|
|
|
|
|
} catch { |
|
343
|
|
|
|
|
|
|
$progress->( ".. failed rmauth $author $name (catch block)" ) if(defined $progress); |
|
344
|
|
|
|
|
|
|
$fail = 1; |
|
345
|
|
|
|
|
|
|
}; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
return 0 if($fail); |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
# remove requests |
|
351
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@ids)},'rmauth',$name); |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
return scalar(@ids); |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub RemoveDistroPages { |
|
357
|
|
|
|
|
|
|
my ($cpan,$dbi,$progress,$name) = @_; |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
# get ids from the page requests |
|
360
|
|
|
|
|
|
|
my @requests = $dbi->GetQuery('hash','GetRequestIDs',{names => $name},'rmdist'); |
|
361
|
|
|
|
|
|
|
my %requests = map { $_->{id} => 1 } grep { $_->{id} } @requests; |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
return unless(keys %requests); |
|
364
|
|
|
|
|
|
|
push my @ids, keys %requests; |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
my $exceptions = $cpan->exceptions; |
|
367
|
|
|
|
|
|
|
my $symlinks = $cpan->symlinks; |
|
368
|
|
|
|
|
|
|
my $merged = $cpan->merged; |
|
369
|
|
|
|
|
|
|
my $ignore = $cpan->ignore; |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
my @delete = ($name); |
|
372
|
|
|
|
|
|
|
if( ( $name =~ /^[A-Za-z0-9][A-Za-z0-9\-_+.]*$/ && !$ignore->{$name} ) |
|
373
|
|
|
|
|
|
|
|| ( $exceptions && $name =~ /$exceptions/ ) ) { |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
# Some distributions are known by multiple names. Rather than create |
|
376
|
|
|
|
|
|
|
# pages for each one, we try and merge them together into one. |
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
my $dist; |
|
379
|
|
|
|
|
|
|
if($symlinks->{$name}) { |
|
380
|
|
|
|
|
|
|
$name = $symlinks->{$name}; |
|
381
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
|
382
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
|
383
|
|
|
|
|
|
|
} elsif($merged->{$name}) { |
|
384
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
|
385
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
|
386
|
|
|
|
|
|
|
} else { |
|
387
|
|
|
|
|
|
|
$dist = $name; |
|
388
|
|
|
|
|
|
|
@delete = ($name); |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
my @valid = $dbi->GetQuery('hash','FindDistro',{dist=>$dist}); |
|
392
|
|
|
|
|
|
|
return unless(@valid); |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/distro/%s", $settings{webdir}, substr($name,0,1); |
|
395
|
|
|
|
|
|
|
my $destfile = "$cache/$name.json"; |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
# get reports |
|
398
|
|
|
|
|
|
|
my (%remove,@reports); |
|
399
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetReportsByIDs',{ids=>join(',',@ids)}); |
|
400
|
|
|
|
|
|
|
while(my $row = $next->()) { |
|
401
|
|
|
|
|
|
|
# hash of dist => summary => PASS, FAIL, NA, UNKNOWN |
|
402
|
|
|
|
|
|
|
$remove{$row->{dist}}{$row->{version}}{uc $row->{state}}++; |
|
403
|
|
|
|
|
|
|
} |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
# load JSON, if we have one |
|
406
|
|
|
|
|
|
|
if(-f $destfile) { |
|
407
|
|
|
|
|
|
|
my $data = read_file($destfile); |
|
408
|
|
|
|
|
|
|
my $store; |
|
409
|
|
|
|
|
|
|
eval { $store = decode_json($data) }; |
|
410
|
|
|
|
|
|
|
if(!$@ && $store) { |
|
411
|
|
|
|
|
|
|
for my $row (@$store) { |
|
412
|
|
|
|
|
|
|
next if($requests{$row->{id}}); # filter out requests |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
push @reports, $row; |
|
415
|
|
|
|
|
|
|
} |
|
416
|
|
|
|
|
|
|
} |
|
417
|
|
|
|
|
|
|
overwrite_file( $destfile, _make_json( \@reports ) ); |
|
418
|
|
|
|
|
|
|
} |
|
419
|
|
|
|
|
|
|
} |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
# remove requests |
|
422
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@ids)},'rmdist',$name); |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
# push in author queue to rebuild pages |
|
425
|
|
|
|
|
|
|
$dbi->DoQuery('PushDistro',$name); |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
return scalar(@ids); |
|
428
|
|
|
|
|
|
|
} |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
# - build author pages |
|
431
|
|
|
|
|
|
|
# - update summary |
|
432
|
|
|
|
|
|
|
# - remove page request entries |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
sub AuthorPages { |
|
435
|
|
|
|
|
|
|
my ($cpan,$dbi,$name,$progress) = @_; |
|
436
|
|
|
|
|
|
|
return unless(defined $name); |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
$name = uc $name; |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
my @ids = (0); |
|
441
|
|
|
|
|
|
|
my %vars = %{ clone (\%tvars) }; |
|
442
|
|
|
|
|
|
|
#LogDebug("AuthorPages: before tvars=".total_size(\%tvars)." bytes"); |
|
443
|
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
my @valid = $dbi->GetQuery('hash','FindAuthor',$name); |
|
445
|
|
|
|
|
|
|
if(@valid) { |
|
446
|
|
|
|
|
|
|
my @dists = $dbi->GetQuery('hash','GetAuthorDists',$name); |
|
447
|
|
|
|
|
|
|
if(@dists) { |
|
448
|
|
|
|
|
|
|
my %dists = map {$_->{dist} => $_->{version}} @dists; |
|
449
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/author/%s", $settings{webdir}, substr($name,0,1); |
|
450
|
|
|
|
|
|
|
mkpath($cache); |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
my (@reports,%reports,%summary,$next); |
|
453
|
|
|
|
|
|
|
my $destfile = "$cache/$name.json"; |
|
454
|
|
|
|
|
|
|
my $fromid = ''; |
|
455
|
|
|
|
|
|
|
my $lastid = 0; |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# load the summary, if we have one |
|
458
|
|
|
|
|
|
|
my @summary = $dbi->GetQuery('hash','GetAuthorSummary',$name); |
|
459
|
|
|
|
|
|
|
$lastid = $summary[0]->{lastid} if(@summary); |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
# load JSON, if we have one |
|
462
|
|
|
|
|
|
|
if(-f $destfile && $lastid) { |
|
463
|
|
|
|
|
|
|
my $data = read_file($destfile); |
|
464
|
|
|
|
|
|
|
my $store; |
|
465
|
|
|
|
|
|
|
eval { $store = decode_json($data); }; |
|
466
|
|
|
|
|
|
|
if(!$@ && $store) { |
|
467
|
|
|
|
|
|
|
my %ids; |
|
468
|
|
|
|
|
|
|
for my $row (@$store) { |
|
469
|
|
|
|
|
|
|
next if($lastid < $row->{id}); |
|
470
|
|
|
|
|
|
|
next if($dists{$row->{dist}} ne $row->{version}); # ensure this is the latest dist version |
|
471
|
|
|
|
|
|
|
next if($ids{$row->{id}}); # auto clean duplicates |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
$ids{$row->{id}} = 1; |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
unshift @{$reports{$row->{dist}}}, $row; |
|
476
|
|
|
|
|
|
|
$summary{$row->{dist}}->{ $row->{status} }++; |
|
477
|
|
|
|
|
|
|
$summary{$row->{dist}}->{ 'ALL' }++; |
|
478
|
|
|
|
|
|
|
push @reports, $row; |
|
479
|
|
|
|
|
|
|
} |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
$fromid = " AND id > $lastid " if($lastid); |
|
482
|
|
|
|
|
|
|
} |
|
483
|
|
|
|
|
|
|
} |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
# if we have ids in the page requests, just update these |
|
486
|
|
|
|
|
|
|
my @requests = $dbi->GetQuery('hash','GetRequestIDs',{names => $name},'author'); |
|
487
|
|
|
|
|
|
|
my %requests = map { $_->{id} => 1 } grep { $_->{id} } @requests; |
|
488
|
|
|
|
|
|
|
if(keys %requests) { |
|
489
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetReportsByIDs',{ids=>join(',',keys %requests)}); |
|
490
|
|
|
|
|
|
|
push @ids, keys %requests; |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
} else { |
|
493
|
|
|
|
|
|
|
# process all the reports from the last ID used |
|
494
|
|
|
|
|
|
|
if(scalar(@dists) > 300) { |
|
495
|
|
|
|
|
|
|
# a fairly constant 83-93 seconds regardless of volume |
|
496
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetAuthorDistReports',{fromid=>$fromid},$name); |
|
497
|
|
|
|
|
|
|
} else { |
|
498
|
|
|
|
|
|
|
# 3-73 secs for dists of 1-100 |
|
499
|
|
|
|
|
|
|
my $lookup = 'AND ( ' . join(' OR ',map {"(dist = '$_->{dist}' AND version = '$_->{version}')"} @dists) . ' )'; |
|
500
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetAuthorDistReports3',{lookup=>$lookup,fromid=>$fromid}); |
|
501
|
|
|
|
|
|
|
} |
|
502
|
|
|
|
|
|
|
} |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
while(my $row = $next->()) { |
|
505
|
|
|
|
|
|
|
next unless($dists{$row->{dist}} && $row->{version}); |
|
506
|
|
|
|
|
|
|
next if($dists{$row->{dist}} ne $row->{version}); # ensure this is the latest dist version |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
$row->{perl} ||= ''; |
|
509
|
|
|
|
|
|
|
$row->{perl} = "5.004_05" if $row->{perl} eq "5.4.4"; # RT 15162 |
|
510
|
|
|
|
|
|
|
$row->{perl} =~ s/patch.*/patch blead/ if $row->{perl} =~ /patch.*blead/; |
|
511
|
|
|
|
|
|
|
my ($osname) = $cpan->OSName($row->{osname}); |
|
512
|
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
$row->{status} = uc $row->{state}; |
|
514
|
|
|
|
|
|
|
$row->{ostext} = $osname; |
|
515
|
|
|
|
|
|
|
$row->{distribution} = $row->{dist}; |
|
516
|
|
|
|
|
|
|
$row->{distversion} = $row->{dist} . '-' . $row->{version}; |
|
517
|
|
|
|
|
|
|
$row->{csspatch} = $row->{perl} =~ /\b(RC\d+|patch)\b/ ? 'pat' : 'unp'; |
|
518
|
|
|
|
|
|
|
$row->{cssperl} = $row->{perl} =~ /^5.(7|9|[1-9][13579])/ ? 'dev' : 'rel'; |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
push @{$reports{$row->{dist}}}, $row; |
|
521
|
|
|
|
|
|
|
$summary{$row->{dist}}->{ $row->{status} }++; |
|
522
|
|
|
|
|
|
|
$summary{$row->{dist}}->{ 'ALL' }++; |
|
523
|
|
|
|
|
|
|
$lastid = $row->{id} if($lastid < $row->{id}); |
|
524
|
|
|
|
|
|
|
unshift @reports, $row; |
|
525
|
|
|
|
|
|
|
} |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
for my $dist (@dists) { |
|
528
|
|
|
|
|
|
|
$dist->{letter} = substr($dist->{dist},0,1); |
|
529
|
|
|
|
|
|
|
$dist->{reports} = 1 if($reports{$dist->{dist}}); |
|
530
|
|
|
|
|
|
|
$dist->{summary} = $summary{$dist->{dist}}; |
|
531
|
|
|
|
|
|
|
$dist->{cssrelease} = $dist->{version} =~ /(_|-TRIAL)/ ? 'rel' : 'off'; |
|
532
|
|
|
|
|
|
|
$dist->{csscurrent} = $dist->{type} eq 'backpan' ? 'back' : 'cpan'; |
|
533
|
|
|
|
|
|
|
} |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
$vars{builder}{author} = $name; |
|
536
|
|
|
|
|
|
|
$vars{builder}{letter} = substr($name,0,1); |
|
537
|
|
|
|
|
|
|
$vars{builder}{title} = 'Reports for distributions by ' . $name; |
|
538
|
|
|
|
|
|
|
$vars{builder}{distributions} = \@dists if(@dists); |
|
539
|
|
|
|
|
|
|
$vars{builder}{processed} = time; |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
# insert summary details |
|
542
|
|
|
|
|
|
|
{ |
|
543
|
|
|
|
|
|
|
my $dataset = encode_json($vars{builder}); |
|
544
|
|
|
|
|
|
|
if(@summary) { $dbi->DoQuery('UpdateAuthorSummary',$lastid,$dataset,$name); } |
|
545
|
|
|
|
|
|
|
else { $dbi->DoQuery('InsertAuthorSummary',$lastid,$dataset,$name); } |
|
546
|
|
|
|
|
|
|
} |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
# we have to do this here as we don't want all the reports in |
|
549
|
|
|
|
|
|
|
# the encoded summary, just whether we have reports or not |
|
550
|
|
|
|
|
|
|
for my $dist (@dists) { |
|
551
|
|
|
|
|
|
|
$dist->{reports} = $reports{$dist->{dist}}; |
|
552
|
|
|
|
|
|
|
} |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
$vars{cache} = $cache; |
|
555
|
|
|
|
|
|
|
$vars{content} = 'cpan/author-reports-static.html'; |
|
556
|
|
|
|
|
|
|
$vars{processed} = formatDate(8); |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
# 2017-06-27 - Static page creation disabled, see GH#6 for more details: https://github.com/barbie/cpan-testers-www-reports/issues/6 |
|
559
|
|
|
|
|
|
|
# # build other static pages |
|
560
|
|
|
|
|
|
|
# my $text = Transform( 'cpan/layout-static.html', \%vars ); |
|
561
|
|
|
|
|
|
|
# overwrite_file( "$cache/$name.html", $text ); |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
my $text = Transform( 'cpan/author.js', \%vars ); |
|
564
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.js", $text ); |
|
565
|
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.json", _make_json( \@reports ) ); |
|
567
|
|
|
|
|
|
|
} |
|
568
|
|
|
|
|
|
|
} |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
#LogDebug("AuthorPages: after tvars=".total_size(\%tvars)." bytes"); |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
# remove requests |
|
573
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@ids)},'author',$name); |
|
574
|
|
|
|
|
|
|
} |
|
575
|
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
# - build distro pages |
|
577
|
|
|
|
|
|
|
# - update summary |
|
578
|
|
|
|
|
|
|
# - remove page request entries |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
sub DistroPages { |
|
581
|
|
|
|
|
|
|
my ($cpan,$dbi,$name,$progress) = @_; |
|
582
|
|
|
|
|
|
|
return unless(defined $name); |
|
583
|
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
my @ids = (0); |
|
585
|
|
|
|
|
|
|
my %vars = %{ clone (\%tvars) }; |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
#LogDebug("DistroPages: before tvars=".total_size(\%tvars)." bytes"); |
|
588
|
|
|
|
|
|
|
#$progress->( ".. .. starting $name" ) if(defined $progress); |
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
my $exceptions = $cpan->exceptions; |
|
591
|
|
|
|
|
|
|
my $symlinks = $cpan->symlinks; |
|
592
|
|
|
|
|
|
|
my $merged = $cpan->merged; |
|
593
|
|
|
|
|
|
|
my $ignore = $cpan->ignore; |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
my @delete = ($name); |
|
596
|
|
|
|
|
|
|
if( ( $name =~ /^[A-Za-z0-9][A-Za-z0-9\-_+.]*$/ && !$ignore->{$name} ) |
|
597
|
|
|
|
|
|
|
|| ( $exceptions && $name =~ /$exceptions/ ) ) { |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
# Some distributions are known by multiple names. Rather than create |
|
600
|
|
|
|
|
|
|
# pages for each one, we try and merge them together into one. |
|
601
|
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
my $dist; |
|
603
|
|
|
|
|
|
|
if($symlinks->{$name}) { |
|
604
|
|
|
|
|
|
|
$name = $symlinks->{$name}; |
|
605
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
|
606
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
|
607
|
|
|
|
|
|
|
} elsif($merged->{$name}) { |
|
608
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
|
609
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
|
610
|
|
|
|
|
|
|
} else { |
|
611
|
|
|
|
|
|
|
$dist = $name; |
|
612
|
|
|
|
|
|
|
@delete = ($name); |
|
613
|
|
|
|
|
|
|
} |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
#$progress->( ".. .. getting records for $name" ) if(defined $progress); |
|
616
|
|
|
|
|
|
|
my @valid = $dbi->GetQuery('hash','FindDistro',{dist=>$dist}); |
|
617
|
|
|
|
|
|
|
#$progress->( ".. .. retrieved records for $name" ) if(defined $progress); |
|
618
|
|
|
|
|
|
|
if(@valid) { |
|
619
|
|
|
|
|
|
|
my (@reports,%authors,%version,$summary,$byversion,$next); |
|
620
|
|
|
|
|
|
|
my $fromid = ''; |
|
621
|
|
|
|
|
|
|
my $lastid = 0; |
|
622
|
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
# determine max dist/version for each pause id |
|
624
|
|
|
|
|
|
|
for(@valid) { |
|
625
|
|
|
|
|
|
|
$authors{$_->{author}} = $_->{version}; |
|
626
|
|
|
|
|
|
|
$version{$_->{version}} = { author => $_->{author}, new => 0, type => $_->{type}}; |
|
627
|
|
|
|
|
|
|
} |
|
628
|
|
|
|
|
|
|
my %reports = map {$authors{$_} => []} keys %authors; |
|
629
|
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
# if we have a summary, process all reports to the last update from the JSON cache |
|
631
|
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
my @summary = $dbi->GetQuery('hash','GetDistroSummary',$name); |
|
633
|
|
|
|
|
|
|
$lastid = $summary[0]->{lastid} if(@summary); |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/distro/%s", $settings{webdir}, substr($name,0,1); |
|
636
|
|
|
|
|
|
|
my $destfile = "$cache/$name.json"; |
|
637
|
|
|
|
|
|
|
mkpath($cache); |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
#$progress->( ".. .. loading JSON data for $name" ) if(defined $progress); |
|
640
|
|
|
|
|
|
|
# load JSON data if available |
|
641
|
|
|
|
|
|
|
if(-f $destfile && $lastid) { |
|
642
|
|
|
|
|
|
|
my $json = read_file($destfile); |
|
643
|
|
|
|
|
|
|
my $data; |
|
644
|
|
|
|
|
|
|
eval { $data = decode_json($json); }; |
|
645
|
|
|
|
|
|
|
if(!$@ && $data) { |
|
646
|
|
|
|
|
|
|
my %ids; |
|
647
|
|
|
|
|
|
|
for my $row (@$data) { |
|
648
|
|
|
|
|
|
|
next if($lastid < $row->{id}); |
|
649
|
|
|
|
|
|
|
next if($ids{$row->{id}}); # auto clean duplicates |
|
650
|
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
$ids{$row->{id}} = 1; |
|
652
|
|
|
|
|
|
|
push @reports, $row; |
|
653
|
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ $row->{status} }++; |
|
655
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ 'ALL' }++; |
|
656
|
|
|
|
|
|
|
unshift @{ $byversion->{ $row->{version} } }, $row; |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
# record reports from max versions |
|
659
|
|
|
|
|
|
|
unshift @{ $reports{$row->{version}} }, $row if(defined $reports{$row->{version}}); |
|
660
|
|
|
|
|
|
|
} |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
$fromid = " AND id > $lastid "; |
|
663
|
|
|
|
|
|
|
} |
|
664
|
|
|
|
|
|
|
} |
|
665
|
|
|
|
|
|
|
#$progress->( ".. .. loaded JSON data for $name" ) if(defined $progress); |
|
666
|
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
# if we have ids in the page requests, just update these |
|
668
|
|
|
|
|
|
|
my @requests = $dbi->GetQuery('hash','GetRequestIDs',{names => $dist},'distro'); |
|
669
|
|
|
|
|
|
|
my %requests = map { $_->{id} => 1 } grep { $_->{id} } @requests; |
|
670
|
|
|
|
|
|
|
if(keys %requests) { |
|
671
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetReportsByIDs',{ids=>join(',',keys %requests)}); |
|
672
|
|
|
|
|
|
|
push @ids, keys %requests; |
|
673
|
|
|
|
|
|
|
} else { |
|
674
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetDistroReports',{fromid => $fromid, dist => $dist}); |
|
675
|
|
|
|
|
|
|
} |
|
676
|
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
#$progress->( ".. .. starting data update for $name" ) if(defined $progress); |
|
678
|
|
|
|
|
|
|
while(my $row = $next->()) { |
|
679
|
|
|
|
|
|
|
$row->{perl} = "5.004_05" if $row->{perl} eq "5.4.4"; # RT 15162 |
|
680
|
|
|
|
|
|
|
$row->{perl} =~ s/patch.*/patch blead/ if $row->{perl} =~ /patch.*blead/; |
|
681
|
|
|
|
|
|
|
my ($osname) = $cpan->OSName($row->{osname}); |
|
682
|
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
$row->{distribution} = $name; |
|
684
|
|
|
|
|
|
|
$row->{status} = uc $row->{state}; |
|
685
|
|
|
|
|
|
|
$row->{ostext} = $osname; |
|
686
|
|
|
|
|
|
|
$row->{osvers} = $row->{osvers}; |
|
687
|
|
|
|
|
|
|
$row->{distversion} = $name . '-' . $row->{version}; |
|
688
|
|
|
|
|
|
|
$row->{csspatch} = $row->{perl} =~ /\b(RC\d+|patch)\b/ ? 'pat' : 'unp'; |
|
689
|
|
|
|
|
|
|
$row->{cssperl} = $row->{perl} =~ /^5.(7|9|[1-9][13579])/ ? 'dev' : 'rel'; |
|
690
|
|
|
|
|
|
|
$lastid = $row->{id} if($lastid < $row->{id}); |
|
691
|
|
|
|
|
|
|
unshift @reports, $row; |
|
692
|
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ $row->{status} }++; |
|
694
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ 'ALL' }++; |
|
695
|
|
|
|
|
|
|
push @{ $byversion->{ $row->{version} } }, $row; |
|
696
|
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
# record reports from max versions |
|
698
|
|
|
|
|
|
|
unshift @{ $reports{$row->{version}} }, $row if($reports{$row->{version}}); |
|
699
|
|
|
|
|
|
|
$version{$row->{version}}->{new} = 1; |
|
700
|
|
|
|
|
|
|
} |
|
701
|
|
|
|
|
|
|
#$progress->( ".. .. summary data update complete for $name" ) if(defined $progress); |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
for my $version ( keys %$byversion ) { |
|
704
|
|
|
|
|
|
|
my @list = @{ $byversion->{$version} }; |
|
705
|
|
|
|
|
|
|
$byversion->{$version} = [ sort { $b->{id} <=> $a->{id} } @list ]; |
|
706
|
|
|
|
|
|
|
} |
|
707
|
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
# ensure we cover all known versions |
|
709
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','GetDistVersions',{dist=>$dist}); |
|
710
|
|
|
|
|
|
|
my @versions = map{$_->[0]} @rows; |
|
711
|
|
|
|
|
|
|
my %versions = map {my $v = $_; $v =~ s/[^\w\.\-]/X/g; $_ => $v} @versions; |
|
712
|
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
my %release; |
|
714
|
|
|
|
|
|
|
for my $version ( keys %versions ) { |
|
715
|
|
|
|
|
|
|
$release{$version}->{csscurrent} = $version{$version}->{type} eq 'backpan' ? 'back' : 'cpan'; |
|
716
|
|
|
|
|
|
|
$release{$version}->{cssrelease} = $version =~ /(_|-TRIAL)/ ? 'dev' : 'off'; |
|
717
|
|
|
|
|
|
|
$release{$version}->{header} = "<h2>$dist $version "; |
|
718
|
|
|
|
|
|
|
if($summary->{$version}{ALL}) { |
|
719
|
|
|
|
|
|
|
$release{$version}->{header} .= "(<b> "; |
|
720
|
|
|
|
|
|
|
for my $status (sort keys %{$summary->{$version}}) { |
|
721
|
|
|
|
|
|
|
$release{$version}->{header} .= "<span class='$status'>$summary->{$version}{$status} $status"; |
|
722
|
|
|
|
|
|
|
if($summary->{$version}{$status} > 1) { |
|
723
|
|
|
|
|
|
|
$release{$version}->{header} .= $status eq 'PASS' ? 'es' : 's'; |
|
724
|
|
|
|
|
|
|
} |
|
725
|
|
|
|
|
|
|
$release{$version}->{header} .= "</span> "; |
|
726
|
|
|
|
|
|
|
} |
|
727
|
|
|
|
|
|
|
$release{$version}->{header} .= "</b>)"; |
|
728
|
|
|
|
|
|
|
} else { |
|
729
|
|
|
|
|
|
|
$release{$version}->{header} .= "(No reports)"; |
|
730
|
|
|
|
|
|
|
} |
|
731
|
|
|
|
|
|
|
$release{$version}->{header} .= "</h2>"; |
|
732
|
|
|
|
|
|
|
} |
|
733
|
|
|
|
|
|
|
#$progress->( ".. .. version data update complete for $name" ) if(defined $progress); |
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
# V1 code starts |
|
736
|
|
|
|
|
|
|
# my ($stats,$oses); |
|
737
|
|
|
|
|
|
|
# @rows = $dbi->GetQuery('hash','GetDistrosPass',{dist=>$dist}); |
|
738
|
|
|
|
|
|
|
# for(@rows) { |
|
739
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
|
740
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{count} = $_->{count}; |
|
741
|
|
|
|
|
|
|
# $oses->{$code} = $osname; |
|
742
|
|
|
|
|
|
|
# } |
|
743
|
|
|
|
|
|
|
##$progress->( ".. .. OS data update complete for $name" ) if(defined $progress); |
|
744
|
|
|
|
|
|
|
# |
|
745
|
|
|
|
|
|
|
# # distribution PASS stats |
|
746
|
|
|
|
|
|
|
# my @stats = $dbi->GetQuery('hash','GetStatsPass',{dist=>$dist}); |
|
747
|
|
|
|
|
|
|
# for(@stats) { |
|
748
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
|
749
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{version} = $_->{version} |
|
750
|
|
|
|
|
|
|
# if(!$stats->{$_->{perl}}->{$code} || _versioncmp($_->{version},$stats->{$_->{perl}}->{$code}{version})); |
|
751
|
|
|
|
|
|
|
# } |
|
752
|
|
|
|
|
|
|
##$progress->( ".. .. Pass Stats data update complete for $name" ) if(defined $progress); |
|
753
|
|
|
|
|
|
|
# V1 code end |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
# V2 code starts |
|
756
|
|
|
|
|
|
|
# # retrieve perl/os stats |
|
757
|
|
|
|
|
|
|
# my ($stats,$oses); |
|
758
|
|
|
|
|
|
|
# my @stats = $dbi->GetQuery('hash','GetStatsPass',{dist=>$dist}); |
|
759
|
|
|
|
|
|
|
# for(@stats) { |
|
760
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
|
761
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{version} = $_->{version} |
|
762
|
|
|
|
|
|
|
# if(!$stats->{$_->{perl}}->{$code} || _versioncmp($_->{version},$stats->{$_->{perl}}->{$code}{version})); |
|
763
|
|
|
|
|
|
|
# |
|
764
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{count}++; |
|
765
|
|
|
|
|
|
|
# $oses->{$code} = $osname; |
|
766
|
|
|
|
|
|
|
# } |
|
767
|
|
|
|
|
|
|
##$progress->( ".. .. Perl/OS data update complete for $name" ) if(defined $progress); |
|
768
|
|
|
|
|
|
|
# V2 code end |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
# V3 code starts |
|
771
|
|
|
|
|
|
|
# retrieve perl/os stats |
|
772
|
|
|
|
|
|
|
my ($stats,$oses); |
|
773
|
|
|
|
|
|
|
my $lastref = 0; |
|
774
|
|
|
|
|
|
|
@rows = $dbi->GetQuery('hash','GetStatsStore',$name); |
|
775
|
|
|
|
|
|
|
for(@rows) { |
|
776
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{storeid} = $_->{storeid}; |
|
777
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{version} = $_->{version}; |
|
778
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{count} = $_->{counter}; |
|
779
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{updated} = 0; |
|
780
|
|
|
|
|
|
|
$oses->{$_->{osname}} = $_->{osname}; |
|
781
|
|
|
|
|
|
|
$lastref = $_->{lastid}; |
|
782
|
|
|
|
|
|
|
} |
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
# update perl/os stats |
|
785
|
|
|
|
|
|
|
my @stats = $dbi->GetQuery('hash','GetStatsPass2',{dist=>$dist},$lastref); |
|
786
|
|
|
|
|
|
|
for(@stats) { |
|
787
|
|
|
|
|
|
|
my ($osname,$code) = $cpan->OSName($_->{osname}); |
|
788
|
|
|
|
|
|
|
my $perl = $_->{perl}; |
|
789
|
|
|
|
|
|
|
$perl =~ s/ .*$//; # don't care about the patch/RC number |
|
790
|
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
$stats->{$perl}{$code}{updated} = 1; |
|
792
|
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
$stats->{$perl}{$code}{version} = $_->{version} |
|
794
|
|
|
|
|
|
|
if(!$stats->{$perl}->{$code} || _versioncmp($_->{version},$stats->{$perl}->{$code}{version})); |
|
795
|
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
$stats->{$perl}{$code}{count}++; |
|
797
|
|
|
|
|
|
|
$oses->{$code} = $osname; |
|
798
|
|
|
|
|
|
|
$lastref = $_->{id} if($lastref < $_->{id}); |
|
799
|
|
|
|
|
|
|
} |
|
800
|
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
# store perl/os stats |
|
802
|
|
|
|
|
|
|
for my $perl (keys %$stats) { |
|
803
|
|
|
|
|
|
|
for my $code (keys %{$stats->{$perl}}) { |
|
804
|
|
|
|
|
|
|
next unless($stats->{$perl}{$code}{updated}); |
|
805
|
|
|
|
|
|
|
if($stats->{$perl}{$code}{storeid}) { |
|
806
|
|
|
|
|
|
|
$dbi->DoQuery('UpdStatsStore',$name,$perl,$code,$stats->{$perl}{$code}{version},$stats->{$perl}{$code}{count},$lastref, $stats->{$perl}{$code}{storeid}); |
|
807
|
|
|
|
|
|
|
} else { |
|
808
|
|
|
|
|
|
|
$dbi->DoQuery('SetStatsStore',$name,$perl,$code,$stats->{$perl}{$code}{version},$stats->{$perl}{$code}{count},$lastref); |
|
809
|
|
|
|
|
|
|
} |
|
810
|
|
|
|
|
|
|
} |
|
811
|
|
|
|
|
|
|
} |
|
812
|
|
|
|
|
|
|
# $dbi->DoQuery('DelStatsStore',$name); |
|
813
|
|
|
|
|
|
|
# for my $perl (keys %$stats) { |
|
814
|
|
|
|
|
|
|
# for my $code (keys %{$stats->{$perl}}) { |
|
815
|
|
|
|
|
|
|
# $dbi->DoQuery('SetStatsStore',$name,$perl,$code,$stats->{$perl}{$code}{version},$stats->{$perl}{$code}{count},$lastref); |
|
816
|
|
|
|
|
|
|
# } |
|
817
|
|
|
|
|
|
|
# } |
|
818
|
|
|
|
|
|
|
#$progress->( ".. .. Perl/OS data update complete for $name" ) if(defined $progress); |
|
819
|
|
|
|
|
|
|
# V3 code end |
|
820
|
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
my @stats_oses = sort keys %$oses; |
|
822
|
|
|
|
|
|
|
my @stats_perl = sort {_versioncmp($b,$a)} keys %$stats; |
|
823
|
|
|
|
|
|
|
my @stats_poff = grep {!/patch/} sort {_versioncmp($b,$a)} keys %$stats; |
|
824
|
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
$vars{title} = 'Reports for distribution ' . $name; |
|
826
|
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
$vars{builder}{distribution} = $name; |
|
828
|
|
|
|
|
|
|
$vars{builder}{letter} = substr($name,0,1); |
|
829
|
|
|
|
|
|
|
$vars{builder}{title} = $vars{title}; |
|
830
|
|
|
|
|
|
|
$vars{builder}{processed} = time; |
|
831
|
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
#$progress->( ".. .. memory data update complete for $name" ) if(defined $progress); |
|
833
|
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
# insert summary details |
|
835
|
|
|
|
|
|
|
{ |
|
836
|
|
|
|
|
|
|
my $dataset = encode_json($vars{builder}); |
|
837
|
|
|
|
|
|
|
if(@summary) { $dbi->DoQuery('UpdateDistroSummary',$lastid,$dataset,$name); } |
|
838
|
|
|
|
|
|
|
else { $dbi->DoQuery('InsertDistroSummary',$lastid,$dataset,$name); } |
|
839
|
|
|
|
|
|
|
} |
|
840
|
|
|
|
|
|
|
#$progress->( ".. .. summary data stored for $name" ) if(defined $progress); |
|
841
|
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
$vars{versions} = \@versions; |
|
843
|
|
|
|
|
|
|
$vars{versions_tag} = \%versions; |
|
844
|
|
|
|
|
|
|
$vars{summary} = $summary; |
|
845
|
|
|
|
|
|
|
$vars{release} = \%release; |
|
846
|
|
|
|
|
|
|
$vars{byversion} = $byversion; |
|
847
|
|
|
|
|
|
|
$vars{cache} = $cache; |
|
848
|
|
|
|
|
|
|
$vars{processed} = formatDate(8); |
|
849
|
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
#$progress->( ".. .. building static pages for $name" ) if(defined $progress); |
|
851
|
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
# 2017-06-27 - Static page creation disabled, see GH#6 for more details: https://github.com/barbie/cpan-testers-www-reports/issues/6 |
|
853
|
|
|
|
|
|
|
# # build other static pages |
|
854
|
|
|
|
|
|
|
# $vars{content} = 'cpan/distro-reports-static.html'; |
|
855
|
|
|
|
|
|
|
# my $text = Transform( 'cpan/layout-static.html', \%vars ); |
|
856
|
|
|
|
|
|
|
# overwrite_file( "$cache/$name.html", $text ); |
|
857
|
|
|
|
|
|
|
##$progress->( ".. .. Static HTML page written for $name" ) if(defined $progress); |
|
858
|
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
my $text = Transform( 'cpan/distro.js', \%vars ); |
|
860
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.js", $text ); |
|
861
|
|
|
|
|
|
|
#$progress->( ".. .. JS page written for $name" ) if(defined $progress); |
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.json", _make_json( \@reports ) ); |
|
864
|
|
|
|
|
|
|
#$progress->( ".. .. JSON page written for $name" ) if(defined $progress); |
|
865
|
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
$cache = sprintf "%s/stats/distro/%s", $settings{webdir}, substr($name,0,1); |
|
867
|
|
|
|
|
|
|
mkpath($cache); |
|
868
|
|
|
|
|
|
|
$vars{cache} = $cache; |
|
869
|
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
$vars{content} = 'cpan/stats-distro-static.html'; |
|
871
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%vars ); |
|
872
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.html", $text ); |
|
873
|
|
|
|
|
|
|
#$progress->( ".. .. Statistics HTML page written for $name" ) if(defined $progress); |
|
874
|
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
# generate symbolic links where necessary |
|
876
|
|
|
|
|
|
|
if($merged->{$name}) { |
|
877
|
|
|
|
|
|
|
my $cwd = getcwd; |
|
878
|
|
|
|
|
|
|
chdir("$settings{webdir}/static/distro"); |
|
879
|
|
|
|
|
|
|
for my $dist (@{$merged->{$name}}) { |
|
880
|
|
|
|
|
|
|
next if($dist eq $name); |
|
881
|
|
|
|
|
|
|
for my $ext (qw(html json js)) { |
|
882
|
|
|
|
|
|
|
my $source = substr($name,0,1) . "/$name.$ext" ; |
|
883
|
|
|
|
|
|
|
my $target = substr($dist,0,1) . "/$dist.$ext" ; |
|
884
|
|
|
|
|
|
|
next if(!-f $source || -f $target); |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
eval {symlink($source,$target) ; 1}; |
|
887
|
|
|
|
|
|
|
} |
|
888
|
|
|
|
|
|
|
} |
|
889
|
|
|
|
|
|
|
chdir($cwd); |
|
890
|
|
|
|
|
|
|
#$progress->( ".. .. symbolic links created for $name" ) if(defined $progress); |
|
891
|
|
|
|
|
|
|
} |
|
892
|
|
|
|
|
|
|
} |
|
893
|
|
|
|
|
|
|
} |
|
894
|
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
#LogDebug("DistroPages: after tvars=".total_size(\%tvars)." bytes"); |
|
896
|
|
|
|
|
|
|
#LogDebug("DistroPages: ids=@ids, distros=@delete"); |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
# remove requests |
|
899
|
|
|
|
|
|
|
while(@ids) { |
|
900
|
|
|
|
|
|
|
#$progress->( ".. .. removing page_request entries for $name. ids=".scalar(@ids) ) if(defined $progress); |
|
901
|
|
|
|
|
|
|
my @remove = splice(@ids,0,100); |
|
902
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@remove)},'distro',$_) for(@delete); |
|
903
|
|
|
|
|
|
|
}; |
|
904
|
|
|
|
|
|
|
#$progress->( ".. .. removed page_request entries for $name" ) if(defined $progress); |
|
905
|
|
|
|
|
|
|
} |
|
906
|
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
sub StatsPages { |
|
908
|
|
|
|
|
|
|
my $cpan = Labyrinth::Plugin::CPAN->new(); |
|
909
|
|
|
|
|
|
|
$cpan->Configure(); |
|
910
|
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
my $cache = sprintf "%s/stats", $settings{webdir}; |
|
912
|
|
|
|
|
|
|
mkpath($cache); |
|
913
|
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
#print STDERR "StatsPages: cache=$cache\n"; |
|
915
|
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
my (%data,%perldata,%perls,%all_osnames,%dists,%perlos,%lookup); |
|
917
|
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
no warnings( 'uninitialized', 'numeric' ); |
|
919
|
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetStats'); |
|
921
|
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
# build data structures |
|
923
|
|
|
|
|
|
|
while ( my $row = $next->() ) { |
|
924
|
|
|
|
|
|
|
#next if not $row->{perl}; |
|
925
|
|
|
|
|
|
|
#next if $row->{perl} =~ / /; |
|
926
|
|
|
|
|
|
|
#next if $row->{perl} =~ /^5\.(7|9|[1-9][13579])\b/; # ignore dev versions |
|
927
|
|
|
|
|
|
|
#next if $row->{version} =~ /[^\d.]/; |
|
928
|
|
|
|
|
|
|
|
|
929
|
|
|
|
|
|
|
$row->{perl} = "5.004_05" if $row->{perl} eq "5.4.4"; # RT 15162 |
|
930
|
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
my ($osname,$oscode) = $cpan->OSName($row->{osname}); |
|
932
|
|
|
|
|
|
|
$row->{osname} = $oscode; |
|
933
|
|
|
|
|
|
|
$lookup{$oscode} = $osname; |
|
934
|
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
$perldata{$row->{perl}}{$row->{dist}} = $row->{version} if $perldata{$row->{perl}}{$row->{dist}} < $row->{version}; |
|
936
|
|
|
|
|
|
|
$data{$row->{dist}}{$row->{perl}}{$row->{osname}} = $row->{version} if $data{$row->{dist}}{$row->{perl}}{$row->{osname}} < $row->{version}; |
|
937
|
|
|
|
|
|
|
$perls{$row->{perl}}{reports}++; |
|
938
|
|
|
|
|
|
|
$perls{$row->{perl}}{distros}{$row->{dist}}++; |
|
939
|
|
|
|
|
|
|
$perlos{$row->{perl}}{$row->{osname}}++; |
|
940
|
|
|
|
|
|
|
$all_osnames{$row->{osname}}++; |
|
941
|
|
|
|
|
|
|
} |
|
942
|
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
my @versions = sort {_versioncmp($b,$a)} keys %perls; |
|
944
|
|
|
|
|
|
|
my $text; |
|
945
|
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
# page perl perl version cross referenced with platforms |
|
947
|
|
|
|
|
|
|
my %perl_osname_all; |
|
948
|
|
|
|
|
|
|
for my $perl ( @versions ) { |
|
949
|
|
|
|
|
|
|
my (@data,%oscounter,%dist_for_perl); |
|
950
|
|
|
|
|
|
|
for my $dist ( sort keys %{ $perldata{$perl} } ) { |
|
951
|
|
|
|
|
|
|
my @osversion; |
|
952
|
|
|
|
|
|
|
for my $oscode ( sort keys %{ $perlos{$perl} } ) { |
|
953
|
|
|
|
|
|
|
if ( defined $data{$dist}{$perl}{$oscode} ) { |
|
954
|
|
|
|
|
|
|
push @osversion, { ver => $data{$dist}{$perl}{$oscode} }; |
|
955
|
|
|
|
|
|
|
$oscounter{$oscode}++; |
|
956
|
|
|
|
|
|
|
$dist_for_perl{$dist}++; |
|
957
|
|
|
|
|
|
|
} else { |
|
958
|
|
|
|
|
|
|
push @osversion, { ver => undef }; |
|
959
|
|
|
|
|
|
|
} |
|
960
|
|
|
|
|
|
|
} |
|
961
|
|
|
|
|
|
|
push @data, { |
|
962
|
|
|
|
|
|
|
dist => $dist, |
|
963
|
|
|
|
|
|
|
osversion => \@osversion, |
|
964
|
|
|
|
|
|
|
}; |
|
965
|
|
|
|
|
|
|
} |
|
966
|
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
my @perl_osnames; |
|
968
|
|
|
|
|
|
|
for my $code ( sort keys %{ $perlos{$perl} } ) { |
|
969
|
|
|
|
|
|
|
if ( $oscounter{$code} ) { |
|
970
|
|
|
|
|
|
|
push @perl_osnames, { oscode => $code, osname => $lookup{$code}, cnt => $oscounter{$code} }; |
|
971
|
|
|
|
|
|
|
$perl_osname_all{$code}{$perl} = $oscounter{$code}; |
|
972
|
|
|
|
|
|
|
} |
|
973
|
|
|
|
|
|
|
} |
|
974
|
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
my $destfile = "perl_${perl}_platforms.html"; |
|
976
|
|
|
|
|
|
|
$tvars{osnames} = \@perl_osnames; |
|
977
|
|
|
|
|
|
|
$tvars{dists} = \@data; |
|
978
|
|
|
|
|
|
|
$tvars{perl} = $perl; |
|
979
|
|
|
|
|
|
|
$tvars{cnt_modules} = scalar keys %dist_for_perl; |
|
980
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
981
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-platform.html'; |
|
982
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
|
983
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
|
984
|
|
|
|
|
|
|
} |
|
985
|
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
my @perl_osnames; |
|
987
|
|
|
|
|
|
|
for(keys %perl_osname_all) { |
|
988
|
|
|
|
|
|
|
my ($name,$code) = $cpan->OSName($_); |
|
989
|
|
|
|
|
|
|
push @perl_osnames, {oscode => $code, osname => $name} |
|
990
|
|
|
|
|
|
|
} |
|
991
|
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
my (@perls,@data_perlplat,$parms,$destfile); |
|
993
|
|
|
|
|
|
|
for my $perl ( @versions ) { |
|
994
|
|
|
|
|
|
|
push @perls, { |
|
995
|
|
|
|
|
|
|
perl => $perl, |
|
996
|
|
|
|
|
|
|
report_count => $perls{$perl}{reports}, |
|
997
|
|
|
|
|
|
|
distro_count => scalar( keys %{ $perls{$perl}{distros} } ), |
|
998
|
|
|
|
|
|
|
}; |
|
999
|
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
my @count; |
|
1001
|
|
|
|
|
|
|
for my $os (keys %perl_osname_all) { |
|
1002
|
|
|
|
|
|
|
my ($name,$code) = $cpan->OSName($os); |
|
1003
|
|
|
|
|
|
|
push @count, { oscode => $code, osname => $name, count => $perl_osname_all{$os}{$perl} }; |
|
1004
|
|
|
|
|
|
|
} |
|
1005
|
|
|
|
|
|
|
push @data_perlplat, { |
|
1006
|
|
|
|
|
|
|
perl => $perl, |
|
1007
|
|
|
|
|
|
|
count => \@count, |
|
1008
|
|
|
|
|
|
|
}; |
|
1009
|
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
my (@data_perl,$cnt); |
|
1011
|
|
|
|
|
|
|
for my $dist ( sort keys %{ $perldata{$perl} } ) { |
|
1012
|
|
|
|
|
|
|
$cnt++; |
|
1013
|
|
|
|
|
|
|
push @data_perl, { |
|
1014
|
|
|
|
|
|
|
dist => $dist, |
|
1015
|
|
|
|
|
|
|
version => $perldata{$perl}{$dist}, |
|
1016
|
|
|
|
|
|
|
}; |
|
1017
|
|
|
|
|
|
|
} |
|
1018
|
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
# page per perl version |
|
1020
|
|
|
|
|
|
|
$destfile = "perl_${perl}.html"; |
|
1021
|
|
|
|
|
|
|
$tvars{data} = \@data_perl; |
|
1022
|
|
|
|
|
|
|
$tvars{perl} = $perl; |
|
1023
|
|
|
|
|
|
|
$tvars{cnt_modules} = $cnt; |
|
1024
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
1025
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-version.html'; |
|
1026
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
|
1027
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
|
1028
|
|
|
|
|
|
|
} |
|
1029
|
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
# how many test reports per platform per perl version? |
|
1031
|
|
|
|
|
|
|
$destfile = "perl_platforms.html"; |
|
1032
|
|
|
|
|
|
|
$tvars{osnames} = \@perl_osnames; |
|
1033
|
|
|
|
|
|
|
$tvars{perlv} = \@data_perlplat; |
|
1034
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
1035
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-platform-count.html'; |
|
1036
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
|
1037
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
|
1038
|
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
# generate index.html |
|
1040
|
|
|
|
|
|
|
$destfile = "index.html"; |
|
1041
|
|
|
|
|
|
|
$tvars{perls} = \@perls; |
|
1042
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
1043
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-index.html'; |
|
1044
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
|
1045
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
|
1046
|
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
# # create symbolic links |
|
1048
|
|
|
|
|
|
|
# for my $link ('headings', 'background.png', 'style.css', 'cpan-testers.css') { |
|
1049
|
|
|
|
|
|
|
# my $source = file( $directory, $link ); |
|
1050
|
|
|
|
|
|
|
# my $target = file( $directory, 'stats', $link ); |
|
1051
|
|
|
|
|
|
|
# next if(!-e $source); |
|
1052
|
|
|
|
|
|
|
# next if( -e $target); |
|
1053
|
|
|
|
|
|
|
# eval {symlink($source,$target) ; 1}; |
|
1054
|
|
|
|
|
|
|
# } |
|
1055
|
|
|
|
|
|
|
} |
|
1056
|
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
sub RecentPage { |
|
1058
|
|
|
|
|
|
|
my $cpan = Labyrinth::Plugin::CPAN->new(); |
|
1059
|
|
|
|
|
|
|
$cpan->Configure(); |
|
1060
|
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
# Recent reports |
|
1062
|
|
|
|
|
|
|
my @recent; |
|
1063
|
|
|
|
|
|
|
my $count = $settings{rss_limit_recent} || $RECENT; |
|
1064
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetRecent',{limit => "LIMIT $count"}); |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
while ( my $row = $next->() ) { |
|
1067
|
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
next unless $row->{version}; |
|
1069
|
|
|
|
|
|
|
my ($name) = $cpan->OSName($row->{osname}); |
|
1070
|
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
my $report = { |
|
1072
|
|
|
|
|
|
|
guid => $row->{guid}, |
|
1073
|
|
|
|
|
|
|
id => $row->{id}, |
|
1074
|
|
|
|
|
|
|
dist => $row->{dist}, |
|
1075
|
|
|
|
|
|
|
status => uc $row->{state}, |
|
1076
|
|
|
|
|
|
|
version => $row->{version}, |
|
1077
|
|
|
|
|
|
|
perl => $row->{perl}, |
|
1078
|
|
|
|
|
|
|
osname => $name, |
|
1079
|
|
|
|
|
|
|
osvers => $row->{osvers}, |
|
1080
|
|
|
|
|
|
|
platform => $row->{platform}, |
|
1081
|
|
|
|
|
|
|
}; |
|
1082
|
|
|
|
|
|
|
push @recent, $report; |
|
1083
|
|
|
|
|
|
|
last if(--$count < 1); |
|
1084
|
|
|
|
|
|
|
} |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
my $cache = sprintf "%s/static", $settings{webdir}; |
|
1087
|
|
|
|
|
|
|
mkpath($cache); |
|
1088
|
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
$tvars{recent} = \@recent; |
|
1090
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
|
1091
|
|
|
|
|
|
|
$tvars{content} = 'cpan/recent.html'; |
|
1092
|
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%tvars ); |
|
1094
|
|
|
|
|
|
|
overwrite_file( $cache . '/recent.html', $text ); |
|
1095
|
|
|
|
|
|
|
$tvars{recent} = undef; |
|
1096
|
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
my $destfile = "$cache/recent.rss"; |
|
1098
|
|
|
|
|
|
|
overwrite_file( $destfile, _make_rss( 'recent', undef, \@recent ) ); |
|
1099
|
|
|
|
|
|
|
} |
|
1100
|
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
1102
|
|
|
|
|
|
|
# Private Interface Functions |
|
1103
|
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
sub _request_count { |
|
1105
|
|
|
|
|
|
|
my $dbi = shift; |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','CountRequests'); |
|
1108
|
|
|
|
|
|
|
my $cnt = @rows ? $rows[0]->[0] : 0; |
|
1109
|
|
|
|
|
|
|
return $cnt; |
|
1110
|
|
|
|
|
|
|
} |
|
1111
|
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
sub _request_oldest { |
|
1113
|
|
|
|
|
|
|
my $dbi = shift; |
|
1114
|
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','OldestRequest'); |
|
1116
|
|
|
|
|
|
|
my $cnt = @rows ? $rows[0]->[0] : 0; |
|
1117
|
|
|
|
|
|
|
return $cnt; |
|
1118
|
|
|
|
|
|
|
} |
|
1119
|
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
sub _make_json { |
|
1121
|
|
|
|
|
|
|
my ( $data ) = @_; |
|
1122
|
|
|
|
|
|
|
return encode_json( $data ); |
|
1123
|
|
|
|
|
|
|
} |
|
1124
|
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
sub _make_rss { |
|
1126
|
|
|
|
|
|
|
my ( $type, $item, $data ) = @_; |
|
1127
|
|
|
|
|
|
|
my ( $title, $link, $desc ); |
|
1128
|
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
if($type eq 'dist') { |
|
1130
|
|
|
|
|
|
|
$title = "$item CPAN Testers Reports"; |
|
1131
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/distro/".substr($item,0,1)."/$item.html"; |
|
1132
|
|
|
|
|
|
|
$desc = "Automated test results for the $item distribution"; |
|
1133
|
|
|
|
|
|
|
} elsif($type eq 'recent') { |
|
1134
|
|
|
|
|
|
|
$title = "Recent CPAN Testers Reports"; |
|
1135
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/static/recent.html"; |
|
1136
|
|
|
|
|
|
|
$desc = "Recent CPAN Testers reports"; |
|
1137
|
|
|
|
|
|
|
} elsif($type eq 'author') { |
|
1138
|
|
|
|
|
|
|
$title = "Reports for distributions by $item"; |
|
1139
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/author/".substr($item,0,1)."/$item.html"; |
|
1140
|
|
|
|
|
|
|
$desc = "Reports for distributions by $item"; |
|
1141
|
|
|
|
|
|
|
} elsif($type eq 'nopass') { |
|
1142
|
|
|
|
|
|
|
$title = "Failing Reports for distributions by $item"; |
|
1143
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/author/".substr($item,0,1)."/$item.html"; |
|
1144
|
|
|
|
|
|
|
$desc = "Reports for distributions by $item"; |
|
1145
|
|
|
|
|
|
|
} |
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
my $rss = XML::RSS->new( version => '1.0' ); |
|
1148
|
|
|
|
|
|
|
$rss->channel( |
|
1149
|
|
|
|
|
|
|
title => $title, |
|
1150
|
|
|
|
|
|
|
link => $link, |
|
1151
|
|
|
|
|
|
|
description => $desc, |
|
1152
|
|
|
|
|
|
|
syn => { |
|
1153
|
|
|
|
|
|
|
updatePeriod => "daily", |
|
1154
|
|
|
|
|
|
|
updateFrequency => "1", |
|
1155
|
|
|
|
|
|
|
updateBase => "1901-01-01T00:00+00:00", |
|
1156
|
|
|
|
|
|
|
}, |
|
1157
|
|
|
|
|
|
|
); |
|
1158
|
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
for my $test (@$data) { |
|
1160
|
|
|
|
|
|
|
$rss->add_item( |
|
1161
|
|
|
|
|
|
|
title => sprintf( |
|
1162
|
|
|
|
|
|
|
"%s %s-%s %s on %s %s (%s)", |
|
1163
|
|
|
|
|
|
|
map {$_||''} |
|
1164
|
|
|
|
|
|
|
@{$test}{ |
|
1165
|
|
|
|
|
|
|
qw( status dist version perl osname osvers platform ) |
|
1166
|
|
|
|
|
|
|
} |
|
1167
|
|
|
|
|
|
|
), |
|
1168
|
|
|
|
|
|
|
link => "$settings{reportlink2}/" . ($test->{guid} || $test->{id}), |
|
1169
|
|
|
|
|
|
|
); |
|
1170
|
|
|
|
|
|
|
} |
|
1171
|
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
return $rss->as_string; |
|
1173
|
|
|
|
|
|
|
} |
|
1174
|
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
sub _versioncmp { |
|
1176
|
|
|
|
|
|
|
my ($v1,$v2) = @_; |
|
1177
|
|
|
|
|
|
|
my ($vn1,$vn2); |
|
1178
|
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
$v1 =~ s/\s.*$// if($v1); |
|
1180
|
|
|
|
|
|
|
$v2 =~ s/\s.*$// if($v2); |
|
1181
|
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
return -1 if(!$v1 && $v2); |
|
1183
|
|
|
|
|
|
|
return 0 if(!$v1 && !$v2); |
|
1184
|
|
|
|
|
|
|
return 1 if( $v1 && !$v2); |
|
1185
|
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
eval { $vn1 = version->parse($v1); }; |
|
1187
|
|
|
|
|
|
|
if($@) { return $v1 cmp $v2 } |
|
1188
|
|
|
|
|
|
|
eval { $vn2 = version->parse($v2); }; |
|
1189
|
|
|
|
|
|
|
if($@) { return $v1 cmp $v2 } |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
return $vn1 cmp $vn2; |
|
1192
|
|
|
|
|
|
|
} |
|
1193
|
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
1; |
|
1195
|
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
__END__ |
|
1197
|
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
1199
|
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
Labyrinth |
|
1201
|
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1203
|
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
Barbie, <barbie@missbarbell.co.uk> for |
|
1205
|
|
|
|
|
|
|
Miss Barbell Productions, L<http://www.missbarbell.co.uk/> |
|
1206
|
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
Copyright (C) 2008-2017 Barbie for Miss Barbell Productions |
|
1210
|
|
|
|
|
|
|
All Rights Reserved. |
|
1211
|
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
1213
|
|
|
|
|
|
|
modify it under the Artistic License 2.0. |
|
1214
|
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
=cut |