Permalink
Browse files

removed JSON & RSS Recent code

  • Loading branch information...
barbie committed Nov 14, 2012
1 parent 0912052 commit 0a7c89e1ed92ff10113fbb441f21d086fa699c58
Showing with 7 additions and 86 deletions.
  1. +2 −0 Changes
  2. +1 −2 META.json
  3. +0 −1 META.yml
  4. +0 −1 Makefile.PL
  5. +0 −4 examples/settings-example.ini
  6. +4 −78 lib/CPAN/Testers/Data/Generator.pm
View
@@ -1,5 +1,7 @@
Revision history for Perl module CPAN::Testers::Data::Generator.
+ - removed JSON & RSS Recent code.
+
1.05 2012-11-13
- parse message fix.
- disabled SQLite updates.
View
@@ -44,8 +44,7 @@
"JSON": "0",
"Metabase": "0.014",
"Metabase::Fact": "0",
- "Time::Local": "0",
- "XML::Feed": "0"
+ "Time::Local": "0"
}
},
"test" : {
View
@@ -32,7 +32,6 @@ requires:
Metabase: 0.014
Metabase::Fact: 0
Time::Local: 0
- XML::Feed: 0
recommends:
Test::CPAN::Meta: 0
Test::CPAN::Meta::JSON: 0
View
@@ -32,7 +32,6 @@ WriteMakefile(
'Metabase' => 0.014,
'Metabase::Fact' => 0,
'Time::Local' => 0,
- 'XML::Feed' => 0,
'DBI' => 0,
'DBD::mysql' => 0,
@@ -1,10 +1,6 @@
[MAIN]
logfile=logs/cpanstats.log
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_namespace=<name>
@@ -20,7 +20,6 @@ use HTML::Entities;
use IO::File;
use JSON;
use Time::Local;
-use XML::RSS;
use Metabase 0.004;
use Metabase::Fact;
@@ -94,14 +93,12 @@ sub new {
}
# 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->{offset} ||= 1;
$self->{poll_limit} ||= 1000;
- $self->{rss_limit} ||= 1000;
- $self->{reportlink} ||= '';
my @rows = $self->{METABASE}->get_query('hash','SELECT * FROM testers_email');
for my $row (@rows) {
@@ -161,21 +158,14 @@ sub generate {
$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");
do {
my $start = localtime(time);
($self->{processed},$self->{stored},$self->{cached}) = (0,0,0);
- my $limit = int($self->{rss_limit} / 5);
- $limit = 500;
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->{stopfile} && -f $self->{stopfile});
@@ -589,11 +579,7 @@ sub get_next_guids {
}
sub retrieve_reports {
- my ($self,$guids,$start,$limit) = @_;
- $limit ||= 0;
- my $count = 0;
-
- my @reports = $self->{reports} ? @{ $self->{reports} } : ();
+ my ($self,$guids,$start) = @_;
if($guids) {
for my $guid (@$guids) {
@@ -608,8 +594,6 @@ sub retrieve_reports {
if($self->store_report()) {
$self->{msg} .= ".. stored";
$self->{stored}++;
- unshift @reports, $report;
- $count++;
} else {
if($self->{time} gt $self->{report}{updated}) {
@@ -623,21 +607,9 @@ sub retrieve_reports {
} else {
$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();
my $invalid = $self->{invalid} ? scalar(@{$self->{invalid}}) : 0;
my $stop = localtime(time);
@@ -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 {
my ($date1,$date2) = @_;
@@ -1540,7 +1466,7 @@ cached report.
=item * retrieve_reports
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

0 comments on commit 0a7c89e

Please sign in to comment.