Permalink
Browse files

reworked versions for version pages

  • Loading branch information...
1 parent f722d5c commit 43a24ef4461520651aa0c7bdbd245d90da7cafad @barbie committed Jun 4, 2014
Showing with 19 additions and 4 deletions.
  1. +19 −4 lib/CPAN/Testers/WWW/Statistics/Pages.pm
@@ -4,7 +4,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '1.12';
+$VERSION = '1.13';
#----------------------------------------------------------------------------
@@ -977,7 +977,7 @@ sub _report_new_distros {
$self->{parent}->_log("building new distro pages");
- my (%seen,%newversions);
+ my (%seen,%allversions,%newversions);
my $start_year = 1995;
my $start_month = 8;
my $this_year = DateTime->now->year;
@@ -999,6 +999,7 @@ sub _report_new_distros {
my @rows = $self->{parent}->{CPANSTATS}->get_query('hash',$sql,$thismon->epoch(),$nextmon->epoch());
for my $row (@rows) {
+ $allversions{$row->{version}}++;
next if($seen{$row->{dist}});
@@ -1021,7 +1022,17 @@ sub _report_new_distros {
$self->{parent}->_log("building new distro versions page");
- my $tvars = { template => 'newversions', versions => \%newversions };
+ my (@allversions,@newversions);
+ for my $v (sort {$allversions{$b} <=> $allversions{$a}} keys %allversions) {
+ push @allversions, { version => $v, count => $allversions{$v} };
+ }
+ my $tvars = { template => 'versions', type => 'All', versions => \@allversions };
+ $self->_writepage("newdistros/allversions",$tvars);
+
+ for my $v (sort {$newversions{$b} <=> $newversions{$a}} keys %newversions) {
+ push @newversions, { version => $v, count => $newversions{$v} };
+ }
+ $tvars = { template => 'versions', type => 'New', versions => \@newversions };
$self->_writepage("newdistros/newversions",$tvars);
}
@@ -1036,7 +1047,7 @@ sub _report_submissions {
my (%hours,%days,%months,%dotw,%tvars);
my $next = $self->{parent}->{CPANSTATS}->iterator('hash',$sql);
- for my $row ($next->()) {
+ while( my $row = $next->() ) {
next unless($row->{reldate} && $row->{reldate} =~ /^(\d+)\-(\d+)\-(\d+).(\d+):(\d+):(\d+)/);
my ($year,$month,$day,$hour,$minute,$second) = ($1,$2,$3,$4,$5,$6);
@@ -1071,27 +1082,31 @@ sub _report_submissions {
my $results = "$directory/rates";
mkpath($results);
+ $self->{parent}->_log("writing $results/submit1.txt");
my $fh = IO::File->new(">$results/submit1.txt");
print $fh "#INDEX,EXCLUSIVE,INCLUSIVE\n";
for my $month (sort {$a <=> $b} keys %{$months{this}}) {
printf $fh "%d,%d,%d\n", $month, $months{this}{$month}, $months{that}{$month};
}
$fh->close;
+ $self->{parent}->_log("writing $results/submit2.txt");
$fh = IO::File->new(">$results/submit2.txt");
print $fh "#INDEX,EXCLUSIVE,INCLUSIVE\n";
for my $dotw (sort {$a <=> $b} keys %{$dotw{this}}) {
printf $fh "%d,%d,%d\n", $dotw, $dotw{this}{$dotw}, $dotw{that}{$dotw};
}
$fh->close;
+ $self->{parent}->_log("writing $results/submit3.txt");
$fh = IO::File->new(">$results/submit3.txt");
print $fh "#INDEX,EXCLUSIVE,INCLUSIVE\n";
for my $day (sort {$a <=> $b} keys %{$days{this}}) {
printf $fh "%d,%d,%d\n", $day, $days{this}{$day}, $days{that}{$day};
}
$fh->close;
+ $self->{parent}->_log("writing $results/submit4.txt");
$fh = IO::File->new(">$results/submit4.txt");
print $fh "#INDEX,EXCLUSIVE,INCLUSIVE\n";
for my $hour (sort {$a <=> $b} keys %{$hours{this}}) {

0 comments on commit 43a24ef

Please sign in to comment.