Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added pages for new distros and new distro versions

  • Loading branch information...
commit e89d30e25d62e355db2e5101b183e74843f26223 1 parent fe2d5e8
@barbie authored
View
3  Changes
@@ -1,6 +1,9 @@
Revision history for CPAN-Testers-WWW-Statistics
================================================
+ - added new distributions pages.
+ - added new distribution versions page.
+
1.12 2014-06-02
- added cpan/backpan 100 files to CPAN Stats page creation.
- DateTime is now a pre-requisite.
View
2  MANIFEST
@@ -135,3 +135,5 @@ t/data/profile.sql
t/data/release_summary.sql
t/data/uploads.sql
t/lib/Fake/Loader.pm
+templates/newdistros.html
+templates/newversions.html
View
59 lib/CPAN/Testers/WWW/Statistics/Pages.pm
@@ -278,7 +278,6 @@ sub build_stats {
$self->{parent}->_log("dist hash from storage built");
if($testers) {
-
for my $tester (keys %$testers) {
$self->{counts}{$testers->{$tester}{first}}{first}++;
$self->{counts}{$testers->{$tester}{last}}{last}++;
@@ -810,8 +809,10 @@ sub _report_cpan {
$stat12->close;
# $stat13->close;
+ $tvars{maxyear} = DateTime->now->year;
$self->_writepage('trends',\%tvars);
+ $self->_report_new_distros();
$self->{parent}->_log("building cpan leader page");
@@ -970,6 +971,59 @@ sub _report_cpan {
$fh->close;
}
+sub _report_new_distros {
+ my $self = shift;
+
+ $self->{parent}->_log("building new distro pages");
+
+ my (%seen,%newversions);
+ my $start_year = 1995;
+ my $start_month = 8;
+ my $this_year = DateTime->now->year;
+ my $sql = 'select author,dist,version,from_unixtime(released) as reldate from uploads where released >= ? AND released < ? order by released';
+
+ for my $year (1995 .. $this_year) {
+ my $tvars = { template => 'newdistros', year => $year };
+
+ for my $month (1 .. 12) {
+ next if($year == $start_year && $month < $start_month);
+
+ my $thismon = DateTime->new( year => $year, month => $month, day => 1, hour => 0, minute => 0, second => 0);
+ my $nextmon = DateTime->new( year => $thismon->clone->add( months => 1 )->year, month => $thismon->clone->add( months => 1 )->month, day => 1, hour => 0, minute => 0, second => 0);
+
+ last if($thismon > DateTime->now);
+
+ $tvars->{newdistros}{$month}{month} = $thismon->month_name;
+ $tvars->{newdistros}{$month}{counter} = 0;
+
+ my @rows = $self->{parent}->{CPANSTATS}->get_query('hash',$sql,$thismon->epoch(),$nextmon->epoch());
+ for my $row (@rows) {
+
+ next if($seen{$row->{dist}});
+
+ $seen{$row->{dist}} = 1;
+ push @{$tvars->{newdistros}{$month}{dists}},
+ {
+ author => $row->{author},
+ dist => $row->{dist},
+ version => $row->{version},
+ reldate => $row->{reldate}
+ };
+
+ $tvars->{newdistros}{$month}{counter}++;
+ $newversions{$row->{version}}++;
+ }
+ }
+
+ $self->_writepage("newdistros/$year",$tvars);
+ }
+
+ $self->{parent}->_log("building new distro versions page");
+
+ my $tvars = { template => 'newversions', versions => \%newversions };
+ $self->_writepage("newdistros/newversions",$tvars);
+}
+
sub _update_noreports {
my $self = shift;
@@ -1920,10 +1974,11 @@ sub _writepage {
my $layout = "$tlayout.$extension";
my $source = "$template.$extension";
my $target = "$directory/$page.$extension";
- mkdir(dirname($target));
#$self->{parent}->_log("_writepage: layout=$layout, source=$source, target=$target");
+ mkdir(dirname($target));
+
$vars->{SOURCE} = $source;
$vars->{VERSION} = $VERSION;
$vars->{copyright} = $self->{parent}->copyright;
View
18 templates/newdistros.html
@@ -0,0 +1,18 @@
+[%
+ box_sites = 1 ;
+
+ title = 'New Distributions submitted during ' _ year;
+ crumb2_name = 'New Distributions' ;
+ crumb2_href = '/newdistros.html' ;
+ crumb1_name = year ;
+%]
+
+[% FOREACH month = newdistros.keys.nsort %]
+<h2>New Distributions for [% newdistros.$month.month %] [% year %] ([% newdistros.$month.counter || '0' %])</h2>
+<table>
+<tr><th class="top">Author</th><th class="top">Distribution</th><th class="top">Version</th><th class="top">Release Date/Time</th></tr>
+[% FOREACH dist = newdistros.$month.dists %]
+<tr><td>[% dist.author %]</td><td>[% dist.dist %]</td><td>[% dist.version %]</td><td class="timestamp1">[% dist.reldate %]</td></tr>
+[% END %]
+</table>
+[% END %]
View
15 templates/newversions.html
@@ -0,0 +1,15 @@
+[%
+ box_sites = 1 ;
+
+ title = 'Versions';
+ crumb2_name = 'New Distributions' ;
+ crumb2_href = '/newdistros.html' ;
+ crumb1_name = 'Versions' ;
+%]
+
+<table>
+<tr><th class="top">Version</th><th class="top">Count</th></tr>
+[% FOREACH version = versions.keys.nsort %]
+<tr><td>[% version %]</td><td>[% versions.$version %]</td></tr>
+[% END %]
+</table>
View
14 templates/trends.html
@@ -10,6 +10,8 @@
<li><a href="#stats6" title="All Distribution Uploads per Month">All Distribution Uploads per Month</a></li>
<li><a href="#stats12" title="New Distribution Uploads per Month">New Distribution Uploads per Month</a></li>
<li><a href="#raw" title="Raw Data">Raw Data</a></li>
+<li><a href="#new" title="Raw Data">New Distributions/a></li>
+<li><a href="#versions" title="Raw Data">Versions</a></li>
</ul>
<h2>Graphs</h2>
@@ -26,4 +28,16 @@ <h2 id="raw">Raw Data</h2>
<li><a href="/stats/stats12.txt" title="raw data for New Uploads">New Distribution Uploads per Month</a></li>
</ul>
+<h2 id="new">New Distributions</h2>
+<ul>
+[% FOREACH year = [ 1995 .. maxyear ] %]
+<li><a href="/newdistros/[% year %].html" title="New Distributions for [% year %]">[% year %]</a></li>
+[% END %]
+</ul>
+
+<h2 id="versions">Versions</h2>
+<ul>
+<li><a href="/newdistros/newversions.html" title="First Versions">First Versions</a></li>
+</ul>
+
<p>Graphs generated using the <a href="http://code.google.com/apis/chart/" title="Google Chart API">Google Chart API</a>.</p>
Please sign in to comment.
Something went wrong with that request. Please try again.