From dbf935e98b8a1eb617267f9167b95141d0edc65a Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Fri, 12 Nov 2010 18:02:50 +0100 Subject: [PATCH 1/2] Unslow bounce report generation and add some extra info as a bonus! --- lib/WebGUI/Mailing/Bounce.pm | 44 +++++++++++++++++++---- lib/WebGUI/i18n/Dutch/MailingManager.pm | 10 +++++- lib/WebGUI/i18n/English/MailingManager.pm | 10 +++++- sbin/install_newsletter.pl | 16 +++++++++ 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/lib/WebGUI/Mailing/Bounce.pm b/lib/WebGUI/Mailing/Bounce.pm index 7a4fe33..c76b572 100644 --- a/lib/WebGUI/Mailing/Bounce.pm +++ b/lib/WebGUI/Mailing/Bounce.pm @@ -57,13 +57,45 @@ sub session { sub www_bounceReport { my $self = shift; my $session = $self->session; + my $db = $session->db; my $i18n = WebGUI::International->new( $session, 'MailingManager' ); - my $sth = $session->db->read( 'select distinct sentTo from Mailing_email where sentTo is not null' ); - - my $output = ''; - while ( my ($email) = $sth->array ) { - my $score = $self->getBounceScore( $email ); - $output .= ""; + + my $windowSize = 10; + + my $sql = <read( $sql, [ $windowSize, $windowSize - 1 ] ); + + my $output = '
'.$i18n->get('email').''.$i18n->get('bounce score').'
$email$score
'; + while ( my $values = $sth->arrayRef ) { + $output .= ''; } $output .= '
' + . join( '', + $i18n->get('email'), + $i18n->get('bounce score'), + $i18n->get('bounce reason'), + $i18n->get('bounce message') + ) + . '
'. join( '', @$values ) . '
'; diff --git a/lib/WebGUI/i18n/Dutch/MailingManager.pm b/lib/WebGUI/i18n/Dutch/MailingManager.pm index 4dc165b..31892b7 100644 --- a/lib/WebGUI/i18n/Dutch/MailingManager.pm +++ b/lib/WebGUI/i18n/Dutch/MailingManager.pm @@ -26,7 +26,7 @@ our $I18N = { 'bounce score' => { message => 'Bounce score', }, - + 'cannot cancel' => { message => 'Mailing \'%s\' kan niet worden afgebroken.', }, @@ -100,6 +100,14 @@ our $I18N = { 'generate mailing' => { message => 'Genereer mailing', }, + + 'bounce reason' => { + message => 'Laatste bounce oorzaak', + }, + + 'bounce message' => { + message => 'Laatste bounce omschrijving', + }, }; 1; diff --git a/lib/WebGUI/i18n/English/MailingManager.pm b/lib/WebGUI/i18n/English/MailingManager.pm index 51798f1..e8aebca 100644 --- a/lib/WebGUI/i18n/English/MailingManager.pm +++ b/lib/WebGUI/i18n/English/MailingManager.pm @@ -26,7 +26,7 @@ our $I18N = { 'bounce score' => { message => 'Bounce score', }, - + 'error' => { message => 'An error occurred', }, @@ -100,6 +100,14 @@ our $I18N = { 'generate mailing' => { message => 'Generate mailing', }, + + 'bounce reason' => { + message => 'Latest bounce reason', + }, + + 'bounce message' => { + message => 'Latest bounce message', + }, }; 1; diff --git a/sbin/install_newsletter.pl b/sbin/install_newsletter.pl index 2d07aea..39b8d37 100644 --- a/sbin/install_newsletter.pl +++ b/sbin/install_newsletter.pl @@ -34,9 +34,25 @@ renamespaceTemplates( $session ); addSpecialStateTable( $session ); addListNameColumn( $session ); addRegistrationSteps( $session ); +addSentToIndex( $session ); finish($session); +#---------------------------------------------------------------------------- +sub addSentToIndex { + my $session = shift; + my $db = $session->db; + + print "\tAdding index to column Mailing_email.sentTo..."; + + my @indexes = $db->buildArray('show indexes from Mailing_email where Column_name=?',['sentTo']); + + if ( @indexes == 0 ) { + $db->write('alter table Mailing_email add index(sentTo)'); + } + + print "Done.\n"; +} #---------------------------------------------------------------------------- sub addListNameColumn { From 5418008419fabfbd37e23f583e5a1f5d89ee5cc3 Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Fri, 19 Nov 2010 13:11:42 +0100 Subject: [PATCH 2/2] Allow empty senderIp and default to 127.0.0.1. --- sbin/newsletter-transport.pl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sbin/newsletter-transport.pl b/sbin/newsletter-transport.pl index beedd33..db49696 100755 --- a/sbin/newsletter-transport.pl +++ b/sbin/newsletter-transport.pl @@ -34,11 +34,9 @@ my $webguiRoot = '/data/WebGUI'; my $session = openSession( $webguiRoot, $configFile ); no warnings 'once'; *{ WebGUI::Session::Env::getIp } = sub { - return $senderIp; + return $senderIp || '127.0.0.1'; }; - $session->log->warn( "IP is : [$senderIp][" .$session->env->getIp ."]"); - WebGUI::MailCommand::processCommand( $session, $command, $id, $sender ); closeSession( $session ); @@ -65,7 +63,7 @@ sub getCredentials { warn "--domain parameter is required" && exit( $WRONG_USAGE ) unless $domain; warn "--user parameter is required" && exit( $WRONG_USAGE ) unless $user; warn "--sender parameter is required" && exit( $WRONG_USAGE ) unless $sender; - warn "--senderIp parameter is required" && exit( $WRONG_USAGE ) unless $senderIp; + #warn "--senderIp parameter is required" && exit( $WRONG_USAGE ) unless $senderIp; my $dispatch = WebGUI::Config->new( $webguiRoot, 'mailing_dispatch.config' ) || warn "Cannot open $webguiRoot/etc/mailing_dispatch.config" && exit( $CONFIG_ERROR );