line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Labyrinth::Plugin::CPAN::Builder; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
13071
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
104
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
108
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
20
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
179
|
|
7
|
|
|
|
|
|
|
$VERSION = '3.58'; |
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
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
336
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
24
|
use Labyrinth::Audit; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
553
|
|
21
|
4
|
|
|
4
|
|
26
|
use Labyrinth::DTUtils; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
247
|
|
22
|
4
|
|
|
4
|
|
23
|
use Labyrinth::MLUtils; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
404
|
|
23
|
4
|
|
|
4
|
|
40
|
use Labyrinth::Mailer; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
199
|
|
24
|
4
|
|
|
4
|
|
21
|
use Labyrinth::Session; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
224
|
|
25
|
4
|
|
|
4
|
|
24
|
use Labyrinth::Support; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
452
|
|
26
|
4
|
|
|
4
|
|
23
|
use Labyrinth::Variables; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
455
|
|
27
|
4
|
|
|
4
|
|
24
|
use Labyrinth::Writer; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
189
|
|
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
|
20
|
use Labyrinth::Plugin::CPAN; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
40
|
|
30
|
4
|
|
|
4
|
|
1751
|
use Labyrinth::Plugin::Articles::Site; |
|
4
|
|
|
|
|
55677
|
|
|
4
|
|
|
|
|
141
|
|
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
4
|
|
33
|
use Clone qw(clone); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
163
|
|
33
|
4
|
|
|
4
|
|
23
|
use Cwd; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
185
|
|
34
|
4
|
|
|
4
|
|
23
|
use File::Path; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
167
|
|
35
|
4
|
|
|
4
|
|
25
|
use File::Slurp; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
200
|
|
36
|
4
|
|
|
4
|
|
22
|
use JSON::XS; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
198
|
|
37
|
|
|
|
|
|
|
#use Sort::Versions; |
38
|
4
|
|
|
4
|
|
20
|
use Time::Local; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
148
|
|
39
|
4
|
|
|
4
|
|
42
|
use Try::Tiny; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
167
|
|
40
|
4
|
|
|
4
|
|
675
|
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}{perlvers} = $cpan->mklist_perls; |
540
|
|
|
|
|
|
|
$vars{builder}{osnames} = $cpan->osnames; |
541
|
|
|
|
|
|
|
$vars{builder}{processed} = time; |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
# insert summary details |
544
|
|
|
|
|
|
|
{ |
545
|
|
|
|
|
|
|
my $dataset = encode_json($vars{builder}); |
546
|
|
|
|
|
|
|
if(@summary) { $dbi->DoQuery('UpdateAuthorSummary',$lastid,$dataset,$name); } |
547
|
|
|
|
|
|
|
else { $dbi->DoQuery('InsertAuthorSummary',$lastid,$dataset,$name); } |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
# we have to do this here as we don't want all the reports in |
551
|
|
|
|
|
|
|
# the encoded summary, just whether we have reports or not |
552
|
|
|
|
|
|
|
for my $dist (@dists) { |
553
|
|
|
|
|
|
|
$dist->{reports} = $reports{$dist->{dist}}; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
$vars{cache} = $cache; |
557
|
|
|
|
|
|
|
$vars{content} = 'cpan/author-reports-static.html'; |
558
|
|
|
|
|
|
|
$vars{processed} = formatDate(8); |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
# build other static pages |
561
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%vars ); |
562
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.html", $text ); |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
$text = Transform( 'cpan/author.js', \%vars ); |
565
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.js", $text ); |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.json", _make_json( \@reports ) ); |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
} |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
#LogDebug("AuthorPages: after tvars=".total_size(\%tvars)." bytes"); |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
# remove requests |
574
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@ids)},'author',$name); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
# - build distro pages |
578
|
|
|
|
|
|
|
# - update summary |
579
|
|
|
|
|
|
|
# - remove page request entries |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
sub DistroPages { |
582
|
|
|
|
|
|
|
my ($cpan,$dbi,$name,$progress) = @_; |
583
|
|
|
|
|
|
|
return unless(defined $name); |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
my @ids = (0); |
586
|
|
|
|
|
|
|
my %vars = %{ clone (\%tvars) }; |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
#LogDebug("DistroPages: before tvars=".total_size(\%tvars)." bytes"); |
589
|
|
|
|
|
|
|
#$progress->( ".. .. starting $name" ) if(defined $progress); |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
my $exceptions = $cpan->exceptions; |
592
|
|
|
|
|
|
|
my $symlinks = $cpan->symlinks; |
593
|
|
|
|
|
|
|
my $merged = $cpan->merged; |
594
|
|
|
|
|
|
|
my $ignore = $cpan->ignore; |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
my @delete = ($name); |
597
|
|
|
|
|
|
|
if( ( $name =~ /^[A-Za-z0-9][A-Za-z0-9\-_+.]*$/ && !$ignore->{$name} ) |
598
|
|
|
|
|
|
|
|| ( $exceptions && $name =~ /$exceptions/ ) ) { |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# Some distributions are known by multiple names. Rather than create |
601
|
|
|
|
|
|
|
# pages for each one, we try and merge them together into one. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
my $dist; |
604
|
|
|
|
|
|
|
if($symlinks->{$name}) { |
605
|
|
|
|
|
|
|
$name = $symlinks->{$name}; |
606
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
607
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
608
|
|
|
|
|
|
|
} elsif($merged->{$name}) { |
609
|
|
|
|
|
|
|
$dist = join("','", @{$merged->{$name}}); |
610
|
|
|
|
|
|
|
@delete = @{$merged->{$name}}; |
611
|
|
|
|
|
|
|
} else { |
612
|
|
|
|
|
|
|
$dist = $name; |
613
|
|
|
|
|
|
|
@delete = ($name); |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
#$progress->( ".. .. getting records for $name" ) if(defined $progress); |
617
|
|
|
|
|
|
|
my @valid = $dbi->GetQuery('hash','FindDistro',{dist=>$dist}); |
618
|
|
|
|
|
|
|
#$progress->( ".. .. retrieved records for $name" ) if(defined $progress); |
619
|
|
|
|
|
|
|
if(@valid) { |
620
|
|
|
|
|
|
|
my (@reports,%authors,%version,$summary,$byversion,$next); |
621
|
|
|
|
|
|
|
my $fromid = ''; |
622
|
|
|
|
|
|
|
my $lastid = 0; |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
# determine max dist/version for each pause id |
625
|
|
|
|
|
|
|
for(@valid) { |
626
|
|
|
|
|
|
|
$authors{$_->{author}} = $_->{version}; |
627
|
|
|
|
|
|
|
$version{$_->{version}} = { author => $_->{author}, new => 0, type => $_->{type}}; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
my %reports = map {$authors{$_} => []} keys %authors; |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
# if we have a summary, process all reports to the last update from the JSON cache |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
my @summary = $dbi->GetQuery('hash','GetDistroSummary',$name); |
634
|
|
|
|
|
|
|
$lastid = $summary[0]->{lastid} if(@summary); |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
my $cache = sprintf "%s/static/distro/%s", $settings{webdir}, substr($name,0,1); |
637
|
|
|
|
|
|
|
my $destfile = "$cache/$name.json"; |
638
|
|
|
|
|
|
|
mkpath($cache); |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
#$progress->( ".. .. loading JSON data for $name" ) if(defined $progress); |
641
|
|
|
|
|
|
|
# load JSON data if available |
642
|
|
|
|
|
|
|
if(-f $destfile && $lastid) { |
643
|
|
|
|
|
|
|
my $json = read_file($destfile); |
644
|
|
|
|
|
|
|
my $data; |
645
|
|
|
|
|
|
|
eval { $data = decode_json($json); }; |
646
|
|
|
|
|
|
|
if(!$@ && $data) { |
647
|
|
|
|
|
|
|
my %ids; |
648
|
|
|
|
|
|
|
for my $row (@$data) { |
649
|
|
|
|
|
|
|
next if($lastid < $row->{id}); |
650
|
|
|
|
|
|
|
next if($ids{$row->{id}}); # auto clean duplicates |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
$ids{$row->{id}} = 1; |
653
|
|
|
|
|
|
|
push @reports, $row; |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ $row->{status} }++; |
656
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ 'ALL' }++; |
657
|
|
|
|
|
|
|
unshift @{ $byversion->{ $row->{version} } }, $row; |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
# record reports from max versions |
660
|
|
|
|
|
|
|
unshift @{ $reports{$row->{version}} }, $row if(defined $reports{$row->{version}}); |
661
|
|
|
|
|
|
|
} |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
$fromid = " AND id > $lastid "; |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
} |
666
|
|
|
|
|
|
|
#$progress->( ".. .. loaded JSON data for $name" ) if(defined $progress); |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
# if we have ids in the page requests, just update these |
669
|
|
|
|
|
|
|
my @requests = $dbi->GetQuery('hash','GetRequestIDs',{names => $dist},'distro'); |
670
|
|
|
|
|
|
|
my %requests = map { $_->{id} => 1 } grep { $_->{id} } @requests; |
671
|
|
|
|
|
|
|
if(keys %requests) { |
672
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetReportsByIDs',{ids=>join(',',keys %requests)}); |
673
|
|
|
|
|
|
|
push @ids, keys %requests; |
674
|
|
|
|
|
|
|
} else { |
675
|
|
|
|
|
|
|
$next = $dbi->Iterator('hash','GetDistroReports',{fromid => $fromid, dist => $dist}); |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
#$progress->( ".. .. starting data update for $name" ) if(defined $progress); |
679
|
|
|
|
|
|
|
while(my $row = $next->()) { |
680
|
|
|
|
|
|
|
$row->{perl} = "5.004_05" if $row->{perl} eq "5.4.4"; # RT 15162 |
681
|
|
|
|
|
|
|
$row->{perl} =~ s/patch.*/patch blead/ if $row->{perl} =~ /patch.*blead/; |
682
|
|
|
|
|
|
|
my ($osname) = $cpan->OSName($row->{osname}); |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
$row->{distribution} = $name; |
685
|
|
|
|
|
|
|
$row->{status} = uc $row->{state}; |
686
|
|
|
|
|
|
|
$row->{ostext} = $osname; |
687
|
|
|
|
|
|
|
$row->{osvers} = $row->{osvers}; |
688
|
|
|
|
|
|
|
$row->{distversion} = $name . '-' . $row->{version}; |
689
|
|
|
|
|
|
|
$row->{csspatch} = $row->{perl} =~ /\b(RC\d+|patch)\b/ ? 'pat' : 'unp'; |
690
|
|
|
|
|
|
|
$row->{cssperl} = $row->{perl} =~ /^5.(7|9|[1-9][13579])/ ? 'dev' : 'rel'; |
691
|
|
|
|
|
|
|
$lastid = $row->{id} if($lastid < $row->{id}); |
692
|
|
|
|
|
|
|
unshift @reports, $row; |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ $row->{status} }++; |
695
|
|
|
|
|
|
|
$summary->{ $row->{version} }->{ 'ALL' }++; |
696
|
|
|
|
|
|
|
push @{ $byversion->{ $row->{version} } }, $row; |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
# record reports from max versions |
699
|
|
|
|
|
|
|
unshift @{ $reports{$row->{version}} }, $row if($reports{$row->{version}}); |
700
|
|
|
|
|
|
|
$version{$row->{version}}->{new} = 1; |
701
|
|
|
|
|
|
|
} |
702
|
|
|
|
|
|
|
#$progress->( ".. .. summary data update complete for $name" ) if(defined $progress); |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
for my $version ( keys %$byversion ) { |
705
|
|
|
|
|
|
|
my @list = @{ $byversion->{$version} }; |
706
|
|
|
|
|
|
|
$byversion->{$version} = [ sort { $b->{id} <=> $a->{id} } @list ]; |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
# ensure we cover all known versions |
710
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','GetDistVersions',{dist=>$dist}); |
711
|
|
|
|
|
|
|
my @versions = map{$_->[0]} @rows; |
712
|
|
|
|
|
|
|
my %versions = map {my $v = $_; $v =~ s/[^\w\.\-]/X/g; $_ => $v} @versions; |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
my %release; |
715
|
|
|
|
|
|
|
for my $version ( keys %versions ) { |
716
|
|
|
|
|
|
|
$release{$version}->{csscurrent} = $version{$version}->{type} eq 'backpan' ? 'back' : 'cpan'; |
717
|
|
|
|
|
|
|
$release{$version}->{cssrelease} = $version =~ /(_|-TRIAL)/ ? 'dev' : 'off'; |
718
|
|
|
|
|
|
|
$release{$version}->{header} = "<h2>$dist $version "; |
719
|
|
|
|
|
|
|
if($summary->{$version}{ALL}) { |
720
|
|
|
|
|
|
|
$release{$version}->{header} .= "(<b> "; |
721
|
|
|
|
|
|
|
for my $status (sort keys %{$summary->{$version}}) { |
722
|
|
|
|
|
|
|
$release{$version}->{header} .= "<span class='$status'>$summary->{$version}{$status} $status"; |
723
|
|
|
|
|
|
|
if($summary->{$version}{$status} > 1) { |
724
|
|
|
|
|
|
|
$release{$version}->{header} .= $status eq 'PASS' ? 'es' : 's'; |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
$release{$version}->{header} .= "</span> "; |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
$release{$version}->{header} .= "</b>)"; |
729
|
|
|
|
|
|
|
} else { |
730
|
|
|
|
|
|
|
$release{$version}->{header} .= "(No reports)"; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
$release{$version}->{header} .= "</h2>"; |
733
|
|
|
|
|
|
|
} |
734
|
|
|
|
|
|
|
#$progress->( ".. .. version data update complete for $name" ) if(defined $progress); |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
# V1 code starts |
737
|
|
|
|
|
|
|
# my ($stats,$oses); |
738
|
|
|
|
|
|
|
# @rows = $dbi->GetQuery('hash','GetDistrosPass',{dist=>$dist}); |
739
|
|
|
|
|
|
|
# for(@rows) { |
740
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
741
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{count} = $_->{count}; |
742
|
|
|
|
|
|
|
# $oses->{$code} = $osname; |
743
|
|
|
|
|
|
|
# } |
744
|
|
|
|
|
|
|
##$progress->( ".. .. OS data update complete for $name" ) if(defined $progress); |
745
|
|
|
|
|
|
|
# |
746
|
|
|
|
|
|
|
# # distribution PASS stats |
747
|
|
|
|
|
|
|
# my @stats = $dbi->GetQuery('hash','GetStatsPass',{dist=>$dist}); |
748
|
|
|
|
|
|
|
# for(@stats) { |
749
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
750
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{version} = $_->{version} |
751
|
|
|
|
|
|
|
# if(!$stats->{$_->{perl}}->{$code} || _versioncmp($_->{version},$stats->{$_->{perl}}->{$code}{version})); |
752
|
|
|
|
|
|
|
# } |
753
|
|
|
|
|
|
|
##$progress->( ".. .. Pass Stats data update complete for $name" ) if(defined $progress); |
754
|
|
|
|
|
|
|
# V1 code end |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
# V2 code starts |
757
|
|
|
|
|
|
|
# # retrieve perl/os stats |
758
|
|
|
|
|
|
|
# my ($stats,$oses); |
759
|
|
|
|
|
|
|
# my @stats = $dbi->GetQuery('hash','GetStatsPass',{dist=>$dist}); |
760
|
|
|
|
|
|
|
# for(@stats) { |
761
|
|
|
|
|
|
|
# my ($osname,$code) = $cpan->OSName($_->{osname}); |
762
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{version} = $_->{version} |
763
|
|
|
|
|
|
|
# if(!$stats->{$_->{perl}}->{$code} || _versioncmp($_->{version},$stats->{$_->{perl}}->{$code}{version})); |
764
|
|
|
|
|
|
|
# |
765
|
|
|
|
|
|
|
# $stats->{$_->{perl}}{$code}{count}++; |
766
|
|
|
|
|
|
|
# $oses->{$code} = $osname; |
767
|
|
|
|
|
|
|
# } |
768
|
|
|
|
|
|
|
##$progress->( ".. .. Perl/OS data update complete for $name" ) if(defined $progress); |
769
|
|
|
|
|
|
|
# V2 code end |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
# V3 code starts |
772
|
|
|
|
|
|
|
# retrieve perl/os stats |
773
|
|
|
|
|
|
|
my ($stats,$oses); |
774
|
|
|
|
|
|
|
my $lastref = 0; |
775
|
|
|
|
|
|
|
@rows = $dbi->GetQuery('hash','GetStatsStore',{dist=>$dist}); |
776
|
|
|
|
|
|
|
for(@rows) { |
777
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{version} = $_->{version}; |
778
|
|
|
|
|
|
|
$stats->{$_->{perl}}{$_->{osname}}{count} = $_->{counter}; |
779
|
|
|
|
|
|
|
$oses->{$_->{osname}} = $_->{osname}; |
780
|
|
|
|
|
|
|
$lastref |= $_->{lastid}; |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
# update perl/os stats |
784
|
|
|
|
|
|
|
my @stats = $dbi->GetQuery('hash','GetStatsPass2',{dist=>$dist},$lastref); |
785
|
|
|
|
|
|
|
for(@stats) { |
786
|
|
|
|
|
|
|
my ($osname,$code) = $cpan->OSName($_->{osname}); |
787
|
|
|
|
|
|
|
my $perl = $_->{perl}; |
788
|
|
|
|
|
|
|
$perl =~ s/ .*$//; # don't care about the patch/RC number |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
$stats->{$perl}{$code}{version} = $_->{version} |
791
|
|
|
|
|
|
|
if(!$stats->{$perl}->{$code} || _versioncmp($_->{version},$stats->{$perl}->{$code}{version})); |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
$stats->{$perl}{$code}{count}++; |
794
|
|
|
|
|
|
|
$oses->{$code} = $osname; |
795
|
|
|
|
|
|
|
$lastref = $_->{id} if($lastref < $_->{id}); |
796
|
|
|
|
|
|
|
} |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
# store perl/os stats |
799
|
|
|
|
|
|
|
$dbi->DoQuery('DelStatsStore',$name); |
800
|
|
|
|
|
|
|
for my $perl (keys %$stats) { |
801
|
|
|
|
|
|
|
for my $code (keys %{$stats->{$perl}}) { |
802
|
|
|
|
|
|
|
$dbi->DoQuery('SetStatsStore',$name,$perl,$code,$stats->{$perl}{$code}{version},$stats->{$perl}{$code}{count},$lastref); |
803
|
|
|
|
|
|
|
} |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
#$progress->( ".. .. Perl/OS data update complete for $name" ) if(defined $progress); |
806
|
|
|
|
|
|
|
# V3 code end |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
my @stats_oses = sort keys %$oses; |
809
|
|
|
|
|
|
|
my @stats_perl = sort {_versioncmp($b,$a)} keys %$stats; |
810
|
|
|
|
|
|
|
my @stats_poff = grep {!/patch/} sort {_versioncmp($b,$a)} keys %$stats; |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
$vars{title} = 'Reports for distribution ' . $name; |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
$vars{builder}{distribution} = $name; |
815
|
|
|
|
|
|
|
$vars{builder}{letter} = substr($name,0,1); |
816
|
|
|
|
|
|
|
$vars{builder}{stats_code} = $oses; |
817
|
|
|
|
|
|
|
$vars{builder}{stats_oses} = \@stats_oses; |
818
|
|
|
|
|
|
|
$vars{builder}{stats_perl} = \@stats_perl; |
819
|
|
|
|
|
|
|
$vars{builder}{stats_poff} = \@stats_poff; |
820
|
|
|
|
|
|
|
$vars{builder}{stats} = $stats; |
821
|
|
|
|
|
|
|
$vars{builder}{title} = $vars{title}; |
822
|
|
|
|
|
|
|
$vars{builder}{perlvers} = $cpan->mklist_perls; |
823
|
|
|
|
|
|
|
$vars{builder}{osnames} = $cpan->osnames; |
824
|
|
|
|
|
|
|
$vars{builder}{processed} = time; |
825
|
|
|
|
|
|
|
#$progress->( ".. .. memory data update complete for $name" ) if(defined $progress); |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
# insert summary details |
828
|
|
|
|
|
|
|
{ |
829
|
|
|
|
|
|
|
my $dataset = encode_json($vars{builder}); |
830
|
|
|
|
|
|
|
if(@summary) { $dbi->DoQuery('UpdateDistroSummary',$lastid,$dataset,$name); } |
831
|
|
|
|
|
|
|
else { $dbi->DoQuery('InsertDistroSummary',$lastid,$dataset,$name); } |
832
|
|
|
|
|
|
|
} |
833
|
|
|
|
|
|
|
#$progress->( ".. .. summary data stored for $name" ) if(defined $progress); |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
$vars{versions} = \@versions; |
836
|
|
|
|
|
|
|
$vars{versions_tag} = \%versions; |
837
|
|
|
|
|
|
|
$vars{summary} = $summary; |
838
|
|
|
|
|
|
|
$vars{release} = \%release; |
839
|
|
|
|
|
|
|
$vars{byversion} = $byversion; |
840
|
|
|
|
|
|
|
$vars{cache} = $cache; |
841
|
|
|
|
|
|
|
$vars{processed} = formatDate(8); |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
#$progress->( ".. .. building static pages for $name" ) if(defined $progress); |
844
|
|
|
|
|
|
|
# build other static pages |
845
|
|
|
|
|
|
|
$vars{content} = 'cpan/distro-reports-static.html'; |
846
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%vars ); |
847
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.html", $text ); |
848
|
|
|
|
|
|
|
#$progress->( ".. .. Dynamic HTML page written for $name" ) if(defined $progress); |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
$text = Transform( 'cpan/distro.js', \%vars ); |
851
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.js", $text ); |
852
|
|
|
|
|
|
|
#$progress->( ".. .. JS page written for $name" ) if(defined $progress); |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.json", _make_json( \@reports ) ); |
855
|
|
|
|
|
|
|
#$progress->( ".. .. JSON page written for $name" ) if(defined $progress); |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
$cache = sprintf "%s/stats/distro/%s", $settings{webdir}, substr($name,0,1); |
858
|
|
|
|
|
|
|
mkpath($cache); |
859
|
|
|
|
|
|
|
$vars{cache} = $cache; |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
$vars{content} = 'cpan/stats-distro-static.html'; |
862
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%vars ); |
863
|
|
|
|
|
|
|
overwrite_file( "$cache/$name.html", $text ); |
864
|
|
|
|
|
|
|
#$progress->( ".. .. Static HTML page written for $name" ) if(defined $progress); |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
# generate symbolic links where necessary |
867
|
|
|
|
|
|
|
if($merged->{$name}) { |
868
|
|
|
|
|
|
|
my $cwd = getcwd; |
869
|
|
|
|
|
|
|
chdir("$settings{webdir}/static/distro"); |
870
|
|
|
|
|
|
|
for my $dist (@{$merged->{$name}}) { |
871
|
|
|
|
|
|
|
next if($dist eq $name); |
872
|
|
|
|
|
|
|
for my $ext (qw(html json js)) { |
873
|
|
|
|
|
|
|
my $source = substr($name,0,1) . "/$name.$ext" ; |
874
|
|
|
|
|
|
|
my $target = substr($dist,0,1) . "/$dist.$ext" ; |
875
|
|
|
|
|
|
|
next if(!-f $source || -f $target); |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
eval {symlink($source,$target) ; 1}; |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
} |
880
|
|
|
|
|
|
|
chdir($cwd); |
881
|
|
|
|
|
|
|
#$progress->( ".. .. symbolic links created for $name" ) if(defined $progress); |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
} |
884
|
|
|
|
|
|
|
} |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
#LogDebug("DistroPages: after tvars=".total_size(\%tvars)." bytes"); |
887
|
|
|
|
|
|
|
#LogDebug("DistroPages: ids=@ids, distros=@delete"); |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
# remove requests |
890
|
|
|
|
|
|
|
while(@ids) { |
891
|
|
|
|
|
|
|
#$progress->( ".. .. removing page_request entries for $name. ids=".scalar(@ids) ) if(defined $progress); |
892
|
|
|
|
|
|
|
my @remove = splice(@ids,0,100); |
893
|
|
|
|
|
|
|
$dbi->DoQuery('DeletePageRequests',{ids => join(',',@remove)},'distro',$_) for(@delete); |
894
|
|
|
|
|
|
|
}; |
895
|
|
|
|
|
|
|
#$progress->( ".. .. removed page_request entries for $name" ) if(defined $progress); |
896
|
|
|
|
|
|
|
} |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
sub StatsPages { |
899
|
|
|
|
|
|
|
my $cpan = Labyrinth::Plugin::CPAN->new(); |
900
|
|
|
|
|
|
|
$cpan->Configure(); |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
my $cache = sprintf "%s/stats", $settings{webdir}; |
903
|
|
|
|
|
|
|
mkpath($cache); |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
#print STDERR "StatsPages: cache=$cache\n"; |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
my (%data,%perldata,%perls,%all_osnames,%dists,%perlos,%lookup); |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
no warnings( 'uninitialized', 'numeric' ); |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetStats'); |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
# build data structures |
914
|
|
|
|
|
|
|
while ( my $row = $next->() ) { |
915
|
|
|
|
|
|
|
#next if not $row->{perl}; |
916
|
|
|
|
|
|
|
#next if $row->{perl} =~ / /; |
917
|
|
|
|
|
|
|
#next if $row->{perl} =~ /^5\.(7|9|[1-9][13579])\b/; # ignore dev versions |
918
|
|
|
|
|
|
|
#next if $row->{version} =~ /[^\d.]/; |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
$row->{perl} = "5.004_05" if $row->{perl} eq "5.4.4"; # RT 15162 |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
my ($osname,$oscode) = $cpan->OSName($row->{osname}); |
923
|
|
|
|
|
|
|
$row->{osname} = $oscode; |
924
|
|
|
|
|
|
|
$lookup{$oscode} = $osname; |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
$perldata{$row->{perl}}{$row->{dist}} = $row->{version} if $perldata{$row->{perl}}{$row->{dist}} < $row->{version}; |
927
|
|
|
|
|
|
|
$data{$row->{dist}}{$row->{perl}}{$row->{osname}} = $row->{version} if $data{$row->{dist}}{$row->{perl}}{$row->{osname}} < $row->{version}; |
928
|
|
|
|
|
|
|
$perls{$row->{perl}}{reports}++; |
929
|
|
|
|
|
|
|
$perls{$row->{perl}}{distros}{$row->{dist}}++; |
930
|
|
|
|
|
|
|
$perlos{$row->{perl}}{$row->{osname}}++; |
931
|
|
|
|
|
|
|
$all_osnames{$row->{osname}}++; |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
my @versions = sort {_versioncmp($b,$a)} keys %perls; |
935
|
|
|
|
|
|
|
my $text; |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
# page perl perl version cross referenced with platforms |
938
|
|
|
|
|
|
|
my %perl_osname_all; |
939
|
|
|
|
|
|
|
for my $perl ( @versions ) { |
940
|
|
|
|
|
|
|
my (@data,%oscounter,%dist_for_perl); |
941
|
|
|
|
|
|
|
for my $dist ( sort keys %{ $perldata{$perl} } ) { |
942
|
|
|
|
|
|
|
my @osversion; |
943
|
|
|
|
|
|
|
for my $oscode ( sort keys %{ $perlos{$perl} } ) { |
944
|
|
|
|
|
|
|
if ( defined $data{$dist}{$perl}{$oscode} ) { |
945
|
|
|
|
|
|
|
push @osversion, { ver => $data{$dist}{$perl}{$oscode} }; |
946
|
|
|
|
|
|
|
$oscounter{$oscode}++; |
947
|
|
|
|
|
|
|
$dist_for_perl{$dist}++; |
948
|
|
|
|
|
|
|
} else { |
949
|
|
|
|
|
|
|
push @osversion, { ver => undef }; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
} |
952
|
|
|
|
|
|
|
push @data, { |
953
|
|
|
|
|
|
|
dist => $dist, |
954
|
|
|
|
|
|
|
osversion => \@osversion, |
955
|
|
|
|
|
|
|
}; |
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
my @perl_osnames; |
959
|
|
|
|
|
|
|
for my $code ( sort keys %{ $perlos{$perl} } ) { |
960
|
|
|
|
|
|
|
if ( $oscounter{$code} ) { |
961
|
|
|
|
|
|
|
push @perl_osnames, { oscode => $code, osname => $lookup{$code}, cnt => $oscounter{$code} }; |
962
|
|
|
|
|
|
|
$perl_osname_all{$code}{$perl} = $oscounter{$code}; |
963
|
|
|
|
|
|
|
} |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
my $destfile = "perl_${perl}_platforms.html"; |
967
|
|
|
|
|
|
|
$tvars{osnames} = \@perl_osnames; |
968
|
|
|
|
|
|
|
$tvars{dists} = \@data; |
969
|
|
|
|
|
|
|
$tvars{perl} = $perl; |
970
|
|
|
|
|
|
|
$tvars{cnt_modules} = scalar keys %dist_for_perl; |
971
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
972
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-platform.html'; |
973
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
974
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
975
|
|
|
|
|
|
|
} |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
my @perl_osnames; |
978
|
|
|
|
|
|
|
for(keys %perl_osname_all) { |
979
|
|
|
|
|
|
|
my ($name,$code) = $cpan->OSName($_); |
980
|
|
|
|
|
|
|
push @perl_osnames, {oscode => $code, osname => $name} |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
my (@perls,@data_perlplat,$parms,$destfile); |
984
|
|
|
|
|
|
|
for my $perl ( @versions ) { |
985
|
|
|
|
|
|
|
push @perls, { |
986
|
|
|
|
|
|
|
perl => $perl, |
987
|
|
|
|
|
|
|
report_count => $perls{$perl}{reports}, |
988
|
|
|
|
|
|
|
distro_count => scalar( keys %{ $perls{$perl}{distros} } ), |
989
|
|
|
|
|
|
|
}; |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
my @count; |
992
|
|
|
|
|
|
|
for my $os (keys %perl_osname_all) { |
993
|
|
|
|
|
|
|
my ($name,$code) = $cpan->OSName($os); |
994
|
|
|
|
|
|
|
push @count, { oscode => $code, osname => $name, count => $perl_osname_all{$os}{$perl} }; |
995
|
|
|
|
|
|
|
} |
996
|
|
|
|
|
|
|
push @data_perlplat, { |
997
|
|
|
|
|
|
|
perl => $perl, |
998
|
|
|
|
|
|
|
count => \@count, |
999
|
|
|
|
|
|
|
}; |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
my (@data_perl,$cnt); |
1002
|
|
|
|
|
|
|
for my $dist ( sort keys %{ $perldata{$perl} } ) { |
1003
|
|
|
|
|
|
|
$cnt++; |
1004
|
|
|
|
|
|
|
push @data_perl, { |
1005
|
|
|
|
|
|
|
dist => $dist, |
1006
|
|
|
|
|
|
|
version => $perldata{$perl}{$dist}, |
1007
|
|
|
|
|
|
|
}; |
1008
|
|
|
|
|
|
|
} |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
# page per perl version |
1011
|
|
|
|
|
|
|
$destfile = "perl_${perl}.html"; |
1012
|
|
|
|
|
|
|
$tvars{data} = \@data_perl; |
1013
|
|
|
|
|
|
|
$tvars{perl} = $perl; |
1014
|
|
|
|
|
|
|
$tvars{cnt_modules} = $cnt; |
1015
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
1016
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-version.html'; |
1017
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
1018
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
1019
|
|
|
|
|
|
|
} |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
# how many test reports per platform per perl version? |
1022
|
|
|
|
|
|
|
$destfile = "perl_platforms.html"; |
1023
|
|
|
|
|
|
|
$tvars{osnames} = \@perl_osnames; |
1024
|
|
|
|
|
|
|
$tvars{perlv} = \@data_perlplat; |
1025
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
1026
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-perl-platform-count.html'; |
1027
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
1028
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
# generate index.html |
1031
|
|
|
|
|
|
|
$destfile = "index.html"; |
1032
|
|
|
|
|
|
|
$tvars{perls} = \@perls; |
1033
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
1034
|
|
|
|
|
|
|
$tvars{content} = 'cpan/stats-index.html'; |
1035
|
|
|
|
|
|
|
$text = Transform( 'cpan/layout-stats-static.html', \%tvars ); |
1036
|
|
|
|
|
|
|
overwrite_file( "$cache/$destfile", $text ); |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
# # create symbolic links |
1039
|
|
|
|
|
|
|
# for my $link ('headings', 'background.png', 'style.css', 'cpan-testers.css') { |
1040
|
|
|
|
|
|
|
# my $source = file( $directory, $link ); |
1041
|
|
|
|
|
|
|
# my $target = file( $directory, 'stats', $link ); |
1042
|
|
|
|
|
|
|
# next if(!-e $source); |
1043
|
|
|
|
|
|
|
# next if( -e $target); |
1044
|
|
|
|
|
|
|
# eval {symlink($source,$target) ; 1}; |
1045
|
|
|
|
|
|
|
# } |
1046
|
|
|
|
|
|
|
} |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
sub RecentPage { |
1049
|
|
|
|
|
|
|
my $cpan = Labyrinth::Plugin::CPAN->new(); |
1050
|
|
|
|
|
|
|
$cpan->Configure(); |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
# Recent reports |
1053
|
|
|
|
|
|
|
my @recent; |
1054
|
|
|
|
|
|
|
my $count = $settings{rss_limit_recent} || $RECENT; |
1055
|
|
|
|
|
|
|
my $next = $dbi->Iterator('hash','GetRecent',{limit => "LIMIT $count"}); |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
while ( my $row = $next->() ) { |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
next unless $row->{version}; |
1060
|
|
|
|
|
|
|
my ($name) = $cpan->OSName($row->{osname}); |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
my $report = { |
1063
|
|
|
|
|
|
|
guid => $row->{guid}, |
1064
|
|
|
|
|
|
|
id => $row->{id}, |
1065
|
|
|
|
|
|
|
dist => $row->{dist}, |
1066
|
|
|
|
|
|
|
status => uc $row->{state}, |
1067
|
|
|
|
|
|
|
version => $row->{version}, |
1068
|
|
|
|
|
|
|
perl => $row->{perl}, |
1069
|
|
|
|
|
|
|
osname => $name, |
1070
|
|
|
|
|
|
|
osvers => $row->{osvers}, |
1071
|
|
|
|
|
|
|
platform => $row->{platform}, |
1072
|
|
|
|
|
|
|
}; |
1073
|
|
|
|
|
|
|
push @recent, $report; |
1074
|
|
|
|
|
|
|
last if(--$count < 1); |
1075
|
|
|
|
|
|
|
} |
1076
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
my $cache = sprintf "%s/static", $settings{webdir}; |
1078
|
|
|
|
|
|
|
mkpath($cache); |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
$tvars{recent} = \@recent; |
1081
|
|
|
|
|
|
|
$tvars{cache} = $cache; |
1082
|
|
|
|
|
|
|
$tvars{content} = 'cpan/recent.html'; |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
my $text = Transform( 'cpan/layout-static.html', \%tvars ); |
1085
|
|
|
|
|
|
|
overwrite_file( $cache . '/recent.html', $text ); |
1086
|
|
|
|
|
|
|
$tvars{recent} = undef; |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
my $destfile = "$cache/recent.rss"; |
1089
|
|
|
|
|
|
|
overwrite_file( $destfile, _make_rss( 'recent', undef, \@recent ) ); |
1090
|
|
|
|
|
|
|
} |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
1093
|
|
|
|
|
|
|
# Private Interface Functions |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
sub _request_count { |
1096
|
|
|
|
|
|
|
my $dbi = shift; |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','CountRequests'); |
1099
|
|
|
|
|
|
|
my $cnt = @rows ? $rows[0]->[0] : 0; |
1100
|
|
|
|
|
|
|
return $cnt; |
1101
|
|
|
|
|
|
|
} |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
sub _request_oldest { |
1104
|
|
|
|
|
|
|
my $dbi = shift; |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('array','OldestRequest'); |
1107
|
|
|
|
|
|
|
my $cnt = @rows ? $rows[0]->[0] : 0; |
1108
|
|
|
|
|
|
|
return $cnt; |
1109
|
|
|
|
|
|
|
} |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
sub _make_json { |
1112
|
|
|
|
|
|
|
my ( $data ) = @_; |
1113
|
|
|
|
|
|
|
return encode_json( $data ); |
1114
|
|
|
|
|
|
|
} |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
sub _make_rss { |
1117
|
|
|
|
|
|
|
my ( $type, $item, $data ) = @_; |
1118
|
|
|
|
|
|
|
my ( $title, $link, $desc ); |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
if($type eq 'dist') { |
1121
|
|
|
|
|
|
|
$title = "$item CPAN Testers Reports"; |
1122
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/distro/".substr($item,0,1)."/$item.html"; |
1123
|
|
|
|
|
|
|
$desc = "Automated test results for the $item distribution"; |
1124
|
|
|
|
|
|
|
} elsif($type eq 'recent') { |
1125
|
|
|
|
|
|
|
$title = "Recent CPAN Testers Reports"; |
1126
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/static/recent.html"; |
1127
|
|
|
|
|
|
|
$desc = "Recent CPAN Testers reports"; |
1128
|
|
|
|
|
|
|
} elsif($type eq 'author') { |
1129
|
|
|
|
|
|
|
$title = "Reports for distributions by $item"; |
1130
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/author/".substr($item,0,1)."/$item.html"; |
1131
|
|
|
|
|
|
|
$desc = "Reports for distributions by $item"; |
1132
|
|
|
|
|
|
|
} elsif($type eq 'nopass') { |
1133
|
|
|
|
|
|
|
$title = "Failing Reports for distributions by $item"; |
1134
|
|
|
|
|
|
|
$link = "http://www.cpantesters.org/author/".substr($item,0,1)."/$item.html"; |
1135
|
|
|
|
|
|
|
$desc = "Reports for distributions by $item"; |
1136
|
|
|
|
|
|
|
} |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
my $rss = XML::RSS->new( version => '1.0' ); |
1139
|
|
|
|
|
|
|
$rss->channel( |
1140
|
|
|
|
|
|
|
title => $title, |
1141
|
|
|
|
|
|
|
link => $link, |
1142
|
|
|
|
|
|
|
description => $desc, |
1143
|
|
|
|
|
|
|
syn => { |
1144
|
|
|
|
|
|
|
updatePeriod => "daily", |
1145
|
|
|
|
|
|
|
updateFrequency => "1", |
1146
|
|
|
|
|
|
|
updateBase => "1901-01-01T00:00+00:00", |
1147
|
|
|
|
|
|
|
}, |
1148
|
|
|
|
|
|
|
); |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
for my $test (@$data) { |
1151
|
|
|
|
|
|
|
$rss->add_item( |
1152
|
|
|
|
|
|
|
title => sprintf( |
1153
|
|
|
|
|
|
|
"%s %s-%s %s on %s %s (%s)", |
1154
|
|
|
|
|
|
|
map {$_||''} |
1155
|
|
|
|
|
|
|
@{$test}{ |
1156
|
|
|
|
|
|
|
qw( status dist version perl osname osvers platform ) |
1157
|
|
|
|
|
|
|
} |
1158
|
|
|
|
|
|
|
), |
1159
|
|
|
|
|
|
|
link => "$settings{reportlink2}/" . ($test->{guid} || $test->{id}), |
1160
|
|
|
|
|
|
|
); |
1161
|
|
|
|
|
|
|
} |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
return $rss->as_string; |
1164
|
|
|
|
|
|
|
} |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
sub _versioncmp { |
1167
|
|
|
|
|
|
|
my ($v1,$v2) = @_; |
1168
|
|
|
|
|
|
|
my ($vn1,$vn2); |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
$v1 =~ s/\s.*$// if($v1); |
1171
|
|
|
|
|
|
|
$v2 =~ s/\s.*$// if($v2); |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
return -1 if(!$v1 && $v2); |
1174
|
|
|
|
|
|
|
return 0 if(!$v1 && !$v2); |
1175
|
|
|
|
|
|
|
return 1 if( $v1 && !$v2); |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
eval { $vn1 = version->parse($v1); }; |
1178
|
|
|
|
|
|
|
if($@) { return $v1 cmp $v2 } |
1179
|
|
|
|
|
|
|
eval { $vn2 = version->parse($v2); }; |
1180
|
|
|
|
|
|
|
if($@) { return $v1 cmp $v2 } |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
return $vn1 cmp $vn2; |
1183
|
|
|
|
|
|
|
} |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
1; |
1186
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
__END__ |
1188
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
=head1 SEE ALSO |
1190
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
Labyrinth |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
=head1 AUTHOR |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
Barbie, <barbie@missbarbell.co.uk> for |
1196
|
|
|
|
|
|
|
Miss Barbell Productions, L<http://www.missbarbell.co.uk/> |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
Copyright (C) 2008-2017 Barbie for Miss Barbell Productions |
1201
|
|
|
|
|
|
|
All Rights Reserved. |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
1204
|
|
|
|
|
|
|
modify it under the Artistic License 2.0. |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=cut |