Permalink
Browse files

altered mail templates, updated count metrics, consoldiated examples

  • Loading branch information...
1 parent 09e2109 commit 88fc2b2c4f5d666cfeb0adf17e281c7e4d9d0d04 barbie committed Jan 19, 2009
View
@@ -1,9 +1,12 @@
Revision history for Perl module CPAN::Testers::WWW::Reports::Mailer.
-0.12 current
+0.12 19/01/2009
- moved to OO style of API.
- updated cpanreps-mailer (0.05) to use new OO API.
- added logging functionality.
+ - altered mail templates
+ - updated and added further count metrics.
+ - moved config example to examples/ and added example shell script.
0.11 18/01/2009
- template website link fixes (thanks to JJ for spotting)
View
@@ -1,6 +1,7 @@
bin/cpanreps-mailer
CHANGES
-data/settings-example.ini
+examples/cpanprefs-mailer.sh
+examples/settings-example.ini
lib/CPAN/Testers/WWW/Reports/Mailer.pm
Makefile.PL
MANIFEST
View
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: CPAN-Testers-WWW-Reports-Mailer
-version: 0.11
+version: 0.12
abstract: CPAN Testers Reports Mailer
author:
- Barbie <barbie@cpan.org>
@@ -30,7 +30,7 @@ requires:
provides:
CPAN::Testers::WWW::Reports::Mailer:
file: lib/CPAN/Testers/WWW/Reports/Mailer.pm
- version: 0.11
+ version: 0.12
meta-spec:
version: 1.4
@@ -0,0 +1,3 @@
+date >xx.out
+perl bin/cpanstats-mailer --config=data/settings-example.ini >>xx.out 2>xx.err
+date >>xx.out
File renamed without changes.
@@ -4,7 +4,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.11';
+$VERSION = '0.12';
=head1 NAME
@@ -55,10 +55,13 @@ use base qw(Class::Accessor::Chained::Fast);
# -------------------------------------
# Variables
-# force default configuration into debug mode
-my %config = (DEBUG => 1);
+# default configuration settings
+my %default = (
+ DEBUG => 1,
+ logclean => 0
+);
-my (%options,%authors,%prefs,%counts);
+my (%AUTHORS,%PREFS);
use constant LASTMAIL => '_lastmail';
use constant DAILY_SUMMARY => 1;
@@ -138,6 +141,7 @@ sub new {
my $self = {};
bless $self, $class;
+ my %options;
GetOptions( \%options,
'config=s',
'logfile=s',
@@ -166,9 +170,9 @@ sub new {
die "Cannot configure $db database\n" unless($self->{$db});
}
- $self->debug( $self->_defined_or( $options{debug}, $hash{debug}, $cfg->val('SETTINGS','DEBUG' ) ) );
+ $self->debug( $self->_defined_or( $options{debug}, $hash{debug}, $cfg->val('SETTINGS','DEBUG' ), $default{debug}) );
$self->logfile( $self->_defined_or( $options{logfile}, $hash{logfile}, $cfg->val('SETTINGS','logfile' ) ) );
- $self->logclean($self->_defined_or( $options{logclean}, $hash{logclean}, $cfg->val('SETTINGS','logclean' ), 0 ) );
+ $self->logclean($self->_defined_or( $options{logclean}, $hash{logclean}, $cfg->val('SETTINGS','logclean' ), $default{logclean} ) );
$self->pause (_download_mailrc());
@@ -215,10 +219,10 @@ sub check_reports {
while( my $row = $rows->()) {
$self->_log( "DEBUG: processing report: $row->{id}\n" ) if($self->debug);
- $counts{REPORTS}++;
+ $self->{counts}{REPORTS}++;
$last_id = $row->{id};
$row->{state} = uc $row->{state};
- $counts{$row->{state}}++;
+ $self->{counts}{$row->{state}}++;
my $author = $self->_get_author($row->{dist}, $row->{version}) || next;
$row->{version} ||= '';
@@ -230,7 +234,7 @@ sub check_reports {
# do we need to worry about this author?
if($prefs->{active} == 2) {
- $counts{NOMAIL}++;
+ $self->{counts}{NOMAIL}++;
next;
}
@@ -298,9 +302,9 @@ sub check_reports {
$self->_log( "DEBUG: processing authors: ".(scalar(keys %reports))."\n" ) if($self->debug);
for my $author (sort keys %reports) {
- $self->_log( "DEBUG: processing mail for author: $author\n" ) if($self->debug);
+ $self->_log( "DEBUG: $author\n" ) if($self->debug);
- my $pause = $$self->pause->author($author);
+ my $pause = $self->pause->author($author);
$tvars{name} = $pause ? $pause->name : $author;
$tvars{author} = $author;
$tvars{dists} = ();
@@ -317,10 +321,18 @@ sub check_reports {
if(!$prefs->{active} || $prefs->{active} == 0) {
$tvars{subject} = 'Welcome to CPAN Testers';
$self->_write_mail('notification.eml',\%tvars);
- $self->{CPANPREFS}->do_query($phrasebook{'InsertAuthorLogin'}, time(), $author);
- $self->{CPANPREFS}->do_query($phrasebook{'InsertDistPrefs'}, $author, '-');
+ $self->{counts}{NEWAUTH}++;
+
+ # insert author defaults, however check that they don't already
+ # exists in the system first, in case entries are out of sync.
+ my @auth = $self->{CPANPREFS}->get_query('hash',$phrasebook{'GetAuthorPrefs'}, $author);
+ $self->{CPANPREFS}->do_query($phrasebook{'InsertAuthorLogin'}, time(), $author) unless(@auth);
+ my @dist = $self->{CPANPREFS}->get_query('hash',$phrasebook{'GetDistPrefs'}, $author,'-');
+ $self->{CPANPREFS}->do_query($phrasebook{'InsertDistPrefs'}, $author, '-') unless(@dist);
}
+ $self->_log( "DEBUG: $author - distributions = ".(scalar(keys %{$reports{$author}->{dists}}))."\n" ) if($self->debug);
+
my ($reports,@e);
for my $dist (keys %{$reports{$author}->{dists}}) {
my $v = $reports{$author}->{dists}{$dist};
@@ -349,22 +361,30 @@ sub check_reports {
}
next unless($reports);
- $self->_log( "DEBUG: reports for author: $author = $reports\n" ) if($self->debug);
+ if($self->debug) { $self->_log( "DEBUG: $author - reports = $reports\n" ) }
+ else { $self->_log( "INFO: $author - dists=".(scalar(keys %{$reports{$author}->{dists}})).", reports=$reports\n" ) }
$tvars{dists} = \@e;
$tvars{subject} = 'CPAN Testers Daily Report';
$self->_write_mail('mailer.eml',\%tvars);
}
- $self->_get_lastid($last_id);
+ $self->_get_lastid($last_id) unless($self->debug);
+ $self->_log( "INFO: new last_id=$last_id\n" );
$self->_log( "INFO: STOP checking reports\n" );
}
sub check_counts {
my $self = shift;
$self->_log( "INFO: COUNTS:\n" );
- $self->_log( sprintf "INFO: %7s = %6d\n", $_, $counts{$_} ) for(keys %counts);
+ my @counts = qw(REPORTS PASS FAIL UNKNOWN NA NOMAIL MAILS NEWAUTH GOOD BAD);
+ push @counts, 'TEST' if($self->debug);
+
+ for(@counts) {
+ $self->{counts}{$_} ||= 0;
+ $self->_log( sprintf "INFO: %7s = %6d\n", $_, $self->{counts}{$_} );
+ }
}
sub help {
@@ -436,11 +456,11 @@ sub _get_author {
my ($dist,$vers) = @_;
return unless($dist && $vers);
- unless($authors{$dist} && $authors{$dist}{$vers}) {
+ unless($AUTHORS{$dist} && $AUTHORS{$dist}{$vers}) {
my @author = $self->{CPANSTATS}->get_query('array',$phrasebook{'GetAuthor'}, $dist, $vers);
- $authors{$dist}{$vers} = @author ? $author[0]->[0] : undef;
+ $AUTHORS{$dist}{$vers} = @author ? $author[0]->[0] : undef;
}
- return $authors{$dist}{$vers};
+ return $AUTHORS{$dist}{$vers};
}
@@ -451,37 +471,37 @@ sub _get_prefs {
# get distribution defaults
if($author && $dist) {
- if(defined $prefs{$author}{dists}{$dist}) {
- return $prefs{$author}{dists}{$dist};
+ if(defined $PREFS{$author}{dists}{$dist}) {
+ return $PREFS{$author}{dists}{$dist};
}
my @rows = $self->{CPANPREFS}->get_query('hash',$phrasebook{'GetDistPrefs'}, $author,$dist);
if(@rows) {
- $prefs{$author}{dists}{$dist} = $self->_parse_prefs($rows[0]);
- return $prefs{$author}{dists}{$dist};
+ $PREFS{$author}{dists}{$dist} = $self->_parse_prefs($rows[0]);
+ return $PREFS{$author}{dists}{$dist};
}
# fall through and assume author defaults
}
# get author defaults
if($author) {
- if(defined $prefs{$author}{default}) {
- return $prefs{$author}{default};
+ if(defined $PREFS{$author}{default}) {
+ return $PREFS{$author}{default};
}
my @auth = $self->{CPANPREFS}->get_query('hash',$phrasebook{'GetAuthorPrefs'}, $author);
if(@auth) {
- $prefs{$author}{default}{active} = $auth[0]->{active} || 0;
+ $PREFS{$author}{default}{active} = $auth[0]->{active} || 0;
my @rows = $self->{CPANPREFS}->get_query('hash',$phrasebook{'GetDefaultPrefs'}, $author);
if(@rows) {
- $prefs{$author}{default} = $self->_parse_prefs($rows[0]);
- $prefs{$author}{default}{active} = $rows[0]->{active} || 0;
- return $prefs{$author}{default};
+ $PREFS{$author}{default} = $self->_parse_prefs($rows[0]);
+ $PREFS{$author}{default}{active} = $rows[0]->{active} || 0;
+ return $PREFS{$author}{default};
} else {
$self->{CPANPREFS}->do_query($phrasebook{'InsertDistPrefs'}, $author, '-');
- $active = $prefs{$author}{default}{active};
+ $active = $PREFS{$author}{default}{active};
}
}
@@ -500,6 +520,7 @@ sub _get_prefs {
perl => 'ALL',
platform => 'ALL',
);
+ $PREFS{$author}{dists}{$dist} = \%prefs;
return \%prefs;
}
@@ -524,39 +545,38 @@ sub _parse_prefs {
}
sub _write_mail {
- my $self = shift;
- my ($template,$parms) = @_;
- my ($text);
+ my ($self,$template,$parms) = @_;
my $subject = $parms->{subject} || 'CPAN Testers Daily Reports';
+ my $cmd = qq!| $HOW $parms->{author}\@cpan.org!;
- $counts{MAILS}++;
-#print "$parms->{author} - $subject\n";
-#return;
+ $self->{counts}{MAILS}++;
- my $DATE = $self->_emaildate();
- $DATE =~ s/\s+$//;
+ if($self->debug) {
+ $self->_log( "INFO: TEST: $parms->{author}\n" );
+ $self->{counts}{TEST}++;
- $self->tt->process( $template, $parms, \$text ) || die $self->tt->error;
+ } elsif(my $fh = IO::File->new($cmd)) {
+ my $DATE = $self->_emaildate();
+ $DATE =~ s/\s+$//;
- my $cmd = qq!| $HOW $parms->{author}\@cpan.org!;
- my $body = $HEAD . $text;
- $body =~ s/NAME/$parms->{name}/g;
- $body =~ s/EMAIL/$parms->{author}\@cpan.org/g;
- $body =~ s/DATE/$DATE/g;
- $body =~ s/SUBJECT/$subject/g;
+ my $text;
+ $self->tt->process( $template, $parms, \$text ) || die $self->tt->error;
- if($self->debug) {
- $self->_log( "INFO: TEST: $parms->{author}\n" );
- return;
- }
+ my $body = $HEAD . $text;
+ $body =~ s/NAME/$parms->{name}/g;
+ $body =~ s/EMAIL/$parms->{author}\@cpan.org/g;
+ $body =~ s/DATE/$DATE/g;
+ $body =~ s/SUBJECT/$subject/g;
- if(my $fh = IO::File->new($cmd)) {
print $fh $body;
$fh->close;
$self->_log( "INFO: GOOD: $parms->{author}\n" );
+ $self->{counts}{GOOD}++;
+
} else {
$self->_log( "INFO: BAD: $parms->{author}\n" );
+ $self->{counts}{BAD}++;
}
}
View
@@ -2,7 +2,7 @@ Dear NAME,
Please find below the latest reports for your distributions, generated by CPAN Testers, from the last 24 hours.
-To set your preferences for what you wish to have reported in this Daily Summary, please visit https://prefs.cpantesters.org.
+To set your preferences for what you wish to have reported in this Daily Summary, please visit the CPAN Testers Preferences system at https://prefs.cpantesters.org.
[% FOREACH dist = dists %]
[% FOREACH vers = dist.versions -%]
@@ -22,11 +22,14 @@ To set your preferences for what you wish to have reported in this Daily Summary
[% END -%]
-This mail is generated by an automated system. If you do not wish to receive these mails, please contact Barbie <barbie@cpan.org> and request to be removed from the automatic mailings. If you have an issue with a particular report, or wish to gain further information from the tester, please use the 'Find A Tester' tool at http://stats.cpantesters.org/cpanmail.html, using the NNTP ID of the report to locate the correct email address.
+If you have an issue with a particular report, or wish to gain further information from the tester, please use the 'Find A Tester' tool at http://stats.cpantesters.org/cpanmail.html, using the NNTP ID of the report to locate the correct email address.
+
+If you wish to unsubscribe from these notifications, please login to the CPAN Testers Preferences system, with your PAUSE credentials, and disable CPAN Testers notifications permanently or temporarily. If you have problems with accessing the site, please contact Barbie <barbie@cpan.org> and request to be removed from the automatic mailings.
Thanks,
The CPAN Testers
--
-Reports: http://www.cpantesters.org
-Statistics: http://stats.cpantesters.org
-Wiki: http://wiki.cpantesters.org
+Reports: http://www.cpantesters.org
+Statistics: http://stats.cpantesters.org
+Wiki: http://wiki.cpantesters.org
+Preferences: https://prefs.cpantesters.org
View
@@ -4,11 +4,11 @@ Welcome to possibly your first exposure to the CPAN related community that is CP
But what does this mean to you? Well hopefully you'll discover the benefits of CPAN Testers as we are able to test your distributions on a variety of platforms, using several different Perl versions, and in a selection of different environments. This all helps to feedback to you as an author any bugs that your users may experience with your distributions, before they have the opportunity of downloading and discovering problems for themselves. The feedback also helps users of your distributions to know what versions of your distributions may or may not work in their environment.
-CPAN Testers has been running for over 10 years, and with its increased success, and with more and more volunteers adding to the distributed network, it can mean that this feedback can be overwhelming. As such we now implement a preferences system for those authors that wish to fine tune the mails they receive. This preferences system is available at https://prefs.cpantesters.org, where you can login with your PAUSE credentials and alter your personal preferences as you wish.
+CPAN Testers has been running for over 10 years. With its increased success, and with more and more volunteers adding to the distributed network, it can mean that this feedback can be overwhelming. As such we now implement a CPAN Testers Preferences system for those authors that wish to fine tune the mails they receive. This CPAN Testers Preferences system is available at https://prefs.cpantesters.org, where you can login with your PAUSE credentials and alter your personal preferences as you wish.
By default a Daily Summary Report is sent collating a list of FAIL reports for each combination of distribution version, perl version and operating system that have been submitted by the distributed smoke bots over the last 24 hours, which you can then read via the perl.org NNTP server.
-The Daily Summary Report is currently the only report available, however future options will implement Weekly Summary Reports as well as the individual reports.
+The Daily Summary Report is currently the only report available, however future options will implement Weekly Summary Reports as well as the ability to receive individual reports.
If you choose to not receive these mails, you may still find a list of reports for all your distributions on the CPAN Testers Reports website - http://www.cpantesters.org. The site also includes an RSS feed that is dedicated to your most recent reports, which you can add to your chosen feed reader at http://www.cpantesters.org/author/[% author %].rss.
@@ -19,6 +19,7 @@ If you wish to find out more about CPAN Testers, please check out our Wiki - htt
Thanks,
The CPAN Testers
--
-Reports: http://www.cpantesters.org
-Statistics: http://stats.cpantesters.org
-Wiki: http://wiki.cpantesters.org
+Reports: http://www.cpantesters.org
+Statistics: http://stats.cpantesters.org
+Wiki: http://wiki.cpantesters.org
+Preferences: https://prefs.cpantesters.org

0 comments on commit 88fc2b2

Please sign in to comment.