Skip to content

Commit

Permalink
storage => mainstore, added leadstore
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Jul 2, 2011
1 parent a383865 commit 43048e6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -12,6 +12,8 @@ Revision history for CPAN-Testers-WWW-Statistics
- reorganised links and names to be consistent across pages.
- restructured Pages.pm, to allow process to be called in stages.
- added terms & conditions page.
- changed storage method to mainstore and added leadstore for JSON data
storage files.

0.88 31/10/2010
- added further timestamp test pattern.
Expand Down
17 changes: 12 additions & 5 deletions lib/CPAN/Testers/WWW/Statistics.pm
Expand Up @@ -55,7 +55,8 @@ keys.
config => path to configuration file [required]
directory => path to output directory
storage => path to data storage file
mainstore => path to main data storage file
leadstore => path to leaderboard data storage file
templates => path to templates directory
database => path to SQLite database file
address => path to address file
Expand Down Expand Up @@ -112,7 +113,8 @@ sub new {
my @TOCOPY = split("\n", $cfg->val('TOCOPY','LIST'));
$self->tocopy(\@TOCOPY);

$self->storage( _defined_or( $hash{storage}, $cfg->val('MASTER','storage' ) ));
$self->mainstore(_defined_or( $hash{mainstore}, $cfg->val('MASTER','mainstore') ));
$self->leadstore(_defined_or( $hash{leadstore}, $cfg->val('MASTER','leadstore') ));
$self->templates(_defined_or( $hash{templates}, $cfg->val('MASTER','templates') ));
$self->database( _defined_or( $hash{database}, $cfg->val('MASTER','database' ) ));
$self->address( _defined_or( $hash{address}, $cfg->val('MASTER','address' ) ));
Expand All @@ -122,7 +124,8 @@ sub new {
$self->copyright( $cfg->val('MASTER','copyright') );
$self->builder( _defined_or( $hash{builder}, $cfg->val('MASTER','builder' ) ));

$self->_log("storage =".($self->storage || ''));
$self->_log("mainstore=".($self->mainstore || ''));
$self->_log("leadstore=".($self->leadstore || ''));
$self->_log("templates=".($self->templates || ''));
$self->_log("database =".($self->database || ''));
$self->_log("address =".($self->address || ''));
Expand Down Expand Up @@ -164,6 +167,10 @@ Method to manage the creation of the matrix style statistics web pages.
Method to manage the creation of the tabular style statistics web pages.
=item * make_leaders
Method to manage the creation of the OS leaderboard web pages.
=item * make_graphs
Method to manage the creation of all the statistics graphs.
Expand All @@ -182,8 +189,8 @@ Returns the print form of a recorded OS name.
=cut

__PACKAGE__->mk_accessors(
qw( directory storage templates database address builder logfile logclean
copyright tocopy osnames));
qw( directory mainstore leadstore templates database address builder
logfile logclean copyright tocopy osnames));

sub make_pages {
my $self = shift;
Expand Down
25 changes: 15 additions & 10 deletions lib/CPAN/Testers/WWW/Statistics/Pages.pm
Expand Up @@ -145,6 +145,10 @@ Create the matrices pages and distribution list pages.
Create all other statistical pages; monthly tables, interesting stats, etc.
=item * build_leaders
Create all OS Leaderboards.
=back
=cut
Expand Down Expand Up @@ -200,6 +204,7 @@ sub update_full {
$self->build_data();
$self->build_matrices();
$self->build_stats();
$self->build_leaders();
$self->{parent}->_log("finish update_full");
}

Expand Down Expand Up @@ -227,7 +232,7 @@ sub build_matrices {
my $self = shift;

$self->{parent}->_log("start build_matrices");
my $storage = $self->{parent}->storage();
my $storage = $self->{parent}->mainstore();
if($storage && -f $storage) {
$self->{parent}->_log("building dist hash from storage");
$self->storage_read($storage);
Expand All @@ -251,7 +256,7 @@ sub build_stats {
$self->_build_monthly_stats();

$self->{parent}->_log("stats start");
my $storage = $self->{parent}->storage();
my $storage = $self->{parent}->mainstore();
if($storage && -f $storage) {
$self->{parent}->_log("building dist hash from storage");
$self->storage_read($storage);
Expand Down Expand Up @@ -319,7 +324,7 @@ sub build_data {

my $testers = {};
my $lastid = 0;
my $storage = $self->{parent}->storage();
my $storage = $self->{parent}->mainstore();
if($storage && -f $storage) {
$self->{parent}->_log("building dist hash from storage");
($testers,$lastid) = $self->storage_read($storage);
Expand Down Expand Up @@ -1213,9 +1218,9 @@ sub _build_osname_leaderboards {
$self->{parent}->_log("building osname leaderboards");

# load data
my $file = 'leaderboard.json';
if(-f $file) {
$json = read_file($file);
my $storage = $self->{parent}->leadstore();
if($storage && -f $storage) {
$json = read_file($storage);
$data = decode_json($json);
}

Expand Down Expand Up @@ -1273,10 +1278,10 @@ sub _build_osname_leaderboards {
}

# save data
$json = encode_json($data);
write_file($file,$json);

$self->{parent}->_log("1.save json");
if($storage) {
$json = encode_json($data);
write_file($storage,$json);
}

# reorganise data
my %hash;
Expand Down

0 comments on commit 43048e6

Please sign in to comment.