Skip to content

Commit

Permalink
pass matrix is now a database table
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Apr 16, 2015
1 parent fe1c120 commit c522171
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,6 +1,9 @@
Revision history for CPAN-Testers-WWW-Statistics
================================================

- pass matrix is now a database table. Changed due to problems storing
as a JSON file.

1.19 2015-02-08
- removed Perl promotions links.
- added Admin site links.
Expand Down
14 changes: 14 additions & 0 deletions examples/cpanstats.sql
Expand Up @@ -110,3 +110,17 @@ CREATE TABLE noreports (
KEY NRIX (dist,version,osname),
KEY OSIX (osname)
);


DROP TABLE IF EXISTS passreports;
CREATE TABLE passreports (
platform varchar(255),
osname varchar(255),
perl varchar(255),
postdate varchar(8),
dist varchar(255),
KEY PLATFORMIX (platform),
KEY OSNAMEIX (osname),
KEY PERLIX (perl),
KEY DATEIX (postdate)
);
21 changes: 17 additions & 4 deletions lib/CPAN/Testers/WWW/Statistics/Pages.pm
Expand Up @@ -457,6 +457,17 @@ sub build_data {
}
#$self->{parent}->_log("build:2.".Dumper($self->{build}));


# load pass matrices
$self->{parent}->_log("building pass reports matrices from database");
my $count = 0;
my $iterator = $dbx->iterator('hash','SELECT * FROM passreports');
while(my $row = $iterator->()) {
$self->{pass} {$row->{platform}}{$row->{perl}}{all}{$row->{dist}} = 1;
$self->{pass} {$row->{platform}}{$row->{perl}}{month}{$row->{postdate}}{$row->{dist}} = 1;
}


# 0, 1, 2, 3, 4, 5 6, 7, 8, 9, 10 11 12
# id, guid, state, postdate, tester, dist, version, platform, perl, osname, osvers, fulldate, type

Expand Down Expand Up @@ -494,13 +505,13 @@ sub build_data {
$perl =~ s/\s.*//; # only need to know the main release
$self->{perls}{$perl} = 1;

$self->{pass} {$row->{platform}}{$perl}{all}{$row->{dist}} = 1;
# $self->{pass} {$row->{platform}}{$perl}{all}{$row->{dist}} = 1;
$self->{platform}{$row->{platform}}{$perl}{all}++;
$self->{osys} {$osname} {$perl}{all}{$row->{dist}} = 1;
$self->{osname} {$osname} {$perl}{all}++;

if($row->{postdate} > $self->{dates}{THATMONTH}) {
$self->{pass} {$row->{platform}}{$perl}{month}{$row->{postdate}}{$row->{dist}} = 1;
# $self->{pass} {$row->{platform}}{$perl}{month}{$row->{postdate}}{$row->{dist}} = 1;
$self->{platform}{$row->{platform}}{$perl}{month}{$row->{postdate}}++;
$self->{osys} {$osname} {$perl}{month}{$row->{postdate}}{$row->{dist}} = 1;
$self->{osname} {$osname} {$perl}{month}{$row->{postdate}}++;
Expand Down Expand Up @@ -568,7 +579,8 @@ sub storage_read {
return $store->{$type};
}

for $type (qw(stats dists fails perls pass platform osys osname build counts count xrefs xlast)) {
# for $type (qw(stats dists fails perls pass platform osys osname build counts count xrefs xlast)) {
for $type (qw(stats dists fails perls platform osys osname build counts count xrefs xlast)) {
my $storage = sprintf $self->{parent}->mainstore(), $type;
next unless(-f $storage);
my $data = read_file($storage);
Expand All @@ -591,7 +603,8 @@ sub storage_write {
return;
}

for $type (qw(stats dists fails perls pass platform osys osname build counts count xrefs xlast)) {
# for $type (qw(stats dists fails perls pass platform osys osname build counts count xrefs xlast)) {
for $type (qw(stats dists fails perls platform osys osname build counts count xrefs xlast)) {
next unless($self->{$type});
my $data = encode_json({$type => $self->{$type}});

Expand Down

0 comments on commit c522171

Please sign in to comment.