Skip to content

Commit

Permalink
removed JSON & RSS Recent code
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Nov 14, 2012
1 parent 0912052 commit 0a7c89e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 86 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@
Revision history for Perl module CPAN::Testers::Data::Generator. Revision history for Perl module CPAN::Testers::Data::Generator.


- removed JSON & RSS Recent code.

1.05 2012-11-13 1.05 2012-11-13
- parse message fix. - parse message fix.
- disabled SQLite updates. - disabled SQLite updates.
Expand Down
3 changes: 1 addition & 2 deletions META.json
Expand Up @@ -44,8 +44,7 @@
"JSON": "0", "JSON": "0",
"Metabase": "0.014", "Metabase": "0.014",
"Metabase::Fact": "0", "Metabase::Fact": "0",
"Time::Local": "0", "Time::Local": "0"
"XML::Feed": "0"
} }
}, },
"test" : { "test" : {
Expand Down
1 change: 0 additions & 1 deletion META.yml
Expand Up @@ -32,7 +32,6 @@ requires:
Metabase: 0.014 Metabase: 0.014
Metabase::Fact: 0 Metabase::Fact: 0
Time::Local: 0 Time::Local: 0
XML::Feed: 0
recommends: recommends:
Test::CPAN::Meta: 0 Test::CPAN::Meta: 0
Test::CPAN::Meta::JSON: 0 Test::CPAN::Meta::JSON: 0
Expand Down
1 change: 0 additions & 1 deletion Makefile.PL
Expand Up @@ -32,7 +32,6 @@ WriteMakefile(
'Metabase' => 0.014, 'Metabase' => 0.014,
'Metabase::Fact' => 0, 'Metabase::Fact' => 0,
'Time::Local' => 0, 'Time::Local' => 0,
'XML::Feed' => 0,


'DBI' => 0, 'DBI' => 0,
'DBD::mysql' => 0, 'DBD::mysql' => 0,
Expand Down
4 changes: 0 additions & 4 deletions examples/settings-example.ini
@@ -1,10 +1,6 @@
[MAIN] [MAIN]
logfile=logs/cpanstats.log logfile=logs/cpanstats.log
poll_limit=2500 poll_limit=2500
json_file=recent.json
rss_file=recent.rss
rss_limit=1000
reportlink=http://www.cpantesters.org/cpan/report


aws_bucket=<bucket> aws_bucket=<bucket>
aws_namespace=<name> aws_namespace=<name>
Expand Down
82 changes: 4 additions & 78 deletions lib/CPAN/Testers/Data/Generator.pm
Expand Up @@ -20,7 +20,6 @@ use HTML::Entities;
use IO::File; use IO::File;
use JSON; use JSON;
use Time::Local; use Time::Local;
use XML::RSS;


use Metabase 0.004; use Metabase 0.004;
use Metabase::Fact; use Metabase::Fact;
Expand Down Expand Up @@ -94,14 +93,12 @@ sub new {
} }


# command line swtiches override configuration settings # command line swtiches override configuration settings
for my $key (qw(logfile poll_limit stopfile offset json_file rss_file rss_limit reportlink aws_bucket aws_namespace)) { for my $key (qw(logfile poll_limit stopfile offset aws_bucket aws_namespace)) {
$self->{$key} = $hash{$key} || $cfg->val('MAIN',$key); $self->{$key} = $hash{$key} || $cfg->val('MAIN',$key);
} }


$self->{offset} ||= 1; $self->{offset} ||= 1;
$self->{poll_limit} ||= 1000; $self->{poll_limit} ||= 1000;
$self->{rss_limit} ||= 1000;
$self->{reportlink} ||= '';


my @rows = $self->{METABASE}->get_query('hash','SELECT * FROM testers_email'); my @rows = $self->{METABASE}->get_query('hash','SELECT * FROM testers_email');
for my $row (@rows) { for my $row (@rows) {
Expand Down Expand Up @@ -161,21 +158,14 @@ sub generate {


$self->{reparse} = 0; $self->{reparse} = 0;


if($self->{json_file} && -f $self->{json_file}) {
my $json = read_file($self->{json_file});
$self->{reports} = decode_json($json);
}

$self->_log("START GENERATE nonstop=$nonstop\n"); $self->_log("START GENERATE nonstop=$nonstop\n");


do { do {
my $start = localtime(time); my $start = localtime(time);
($self->{processed},$self->{stored},$self->{cached}) = (0,0,0); ($self->{processed},$self->{stored},$self->{cached}) = (0,0,0);
my $limit = int($self->{rss_limit} / 5);
$limit = 500;


my $guids = $self->get_next_guids(); my $guids = $self->get_next_guids();
$self->retrieve_reports($guids,$start,$limit); $self->retrieve_reports($guids,$start);


$nonstop = 0 if($self->{processed} == 0); $nonstop = 0 if($self->{processed} == 0);
$nonstop = 0 if($self->{stopfile} && -f $self->{stopfile}); $nonstop = 0 if($self->{stopfile} && -f $self->{stopfile});
Expand Down Expand Up @@ -589,11 +579,7 @@ sub get_next_guids {
} }


sub retrieve_reports { sub retrieve_reports {
my ($self,$guids,$start,$limit) = @_; my ($self,$guids,$start) = @_;
$limit ||= 0;
my $count = 0;

my @reports = $self->{reports} ? @{ $self->{reports} } : ();


if($guids) { if($guids) {
for my $guid (@$guids) { for my $guid (@$guids) {
Expand All @@ -608,8 +594,6 @@ sub retrieve_reports {
if($self->store_report()) { if($self->store_report()) {
$self->{msg} .= ".. stored"; $self->{msg} .= ".. stored";
$self->{stored}++; $self->{stored}++;
unshift @reports, $report;
$count++;


} else { } else {
if($self->{time} gt $self->{report}{updated}) { if($self->{time} gt $self->{report}{updated}) {
Expand All @@ -623,21 +607,9 @@ sub retrieve_reports {
} else { } else {
$self->_log(".. FAIL\n"); $self->_log(".. FAIL\n");
} }

if($limit && $count % $limit == 0) {
splice(@reports,0,$self->{rss_limit}) if(scalar(@reports) > $self->{rss_limit});
#overwrite_file( $self->{rss_file}, $self->_make_rss( \@reports ) ) if($self->{rss_file});
}
} }
} }


# store recent files
if($limit){
splice(@reports,0,$self->{rss_limit}) if(scalar(@reports) > $self->{rss_limit});
#overwrite_file( $self->{json_file}, $self->_make_json( \@reports ) ) if($self->{json_file});
#overwrite_file( $self->{rss_file}, $self->_make_rss( \@reports ) ) if($self->{rss_file});
}

$self->commit(); $self->commit();
my $invalid = $self->{invalid} ? scalar(@{$self->{invalid}}) : 0; my $invalid = $self->{invalid} ? scalar(@{$self->{invalid}}) : 0;
my $stop = localtime(time); my $stop = localtime(time);
Expand Down Expand Up @@ -1244,52 +1216,6 @@ sub _send_email {
} }
} }


sub _make_json {
my ( $self, $data ) = @_;
return encode_json( $data );
}

sub _make_rss {
my ( $self, $data ) = @_;

my $title = "Recent CPAN Testers Reports";
my $link = "http://www.cpantesters.org/static/recent.html";
my $desc = "Recent CPAN Testers reports";

my @date = $data->[0]->{fulldate} =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/;
my $date = sprintf "%04d-%02d-%02dT%02d:%02d+01:00", @date;

my $rss = XML::RSS->new( version => '1.0' );
$rss->channel(
title => $title,
link => $link,
description => $desc,
syn => {
updatePeriod => "daily",
updateFrequency => "1",
updateBase => "1901-01-01T00:00+00:00",
},
dc => {
date => $date,
subject => $desc,
creator => 'barbie@cpantesters.org',
publisher => 'barbie@cpantesters.org',
rights => 'Copyright ' . $date[0] . ', CPAN Testers',
language => 'en-gb'
}
);

for my $test (@$data) {
my @fields = map {$test->{$_} || ''} qw( status dist version perl osname osvers platform );
$rss->add_item(
title => sprintf( "%s %s-%s %s on %s %s (%s)", @fields ),
link => "$self->{reportlink}/" . ($test->{guid} || $test->{id}),
);
}

return $rss->as_string;
}

sub _date_diff { sub _date_diff {
my ($date1,$date2) = @_; my ($date1,$date2) = @_;


Expand Down Expand Up @@ -1540,7 +1466,7 @@ cached report.
=item * retrieve_reports =item * retrieve_reports
Abstracted loop of requesting GUIDs, then parsing, storing and caching each Abstracted loop of requesting GUIDs, then parsing, storing and caching each
report as appropriate. Updates Recent JSON & RSS files. report as appropriate.
=item * already_saved =item * already_saved
Expand Down

0 comments on commit 0a7c89e

Please sign in to comment.