Unslow bounce report generation and add some extra info as a bonus!
This commit is contained in:
parent
0843bec5e0
commit
d325e7a301
4 changed files with 68 additions and 8 deletions
|
|
@ -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 = '<table><tr><th>'.$i18n->get('email').'</th><th>'.$i18n->get('bounce score').'</th></tr>';
|
||||
while ( my ($email) = $sth->array ) {
|
||||
my $score = $self->getBounceScore( $email );
|
||||
$output .= "<tr><td>$email</td><td>$score</td></tr>";
|
||||
my $windowSize = 10;
|
||||
|
||||
my $sql = <<EOSQL;
|
||||
select
|
||||
sentTo,
|
||||
count(status),
|
||||
bounceReason,
|
||||
errorMessage
|
||||
from
|
||||
Mailing_email as t1
|
||||
where
|
||||
status='bounced'
|
||||
and
|
||||
(
|
||||
(select count(*) from Mailing_email as t2 where t1.sentTo=t2.sentTo) < ?
|
||||
or
|
||||
(select lastUpdated from Mailing_email as t2 where t1.sentTo=t2.sentTo order by lastUpdated desc limit ?,1 )
|
||||
)
|
||||
group by
|
||||
sentTo
|
||||
order by
|
||||
sentTo, lastUpdated
|
||||
EOSQL
|
||||
|
||||
my $sth = $db->read( $sql, [ $windowSize, $windowSize - 1 ] );
|
||||
|
||||
my $output = '<table><tr><th>'
|
||||
. join( '</th><th>',
|
||||
$i18n->get('email'),
|
||||
$i18n->get('bounce score'),
|
||||
$i18n->get('bounce reason'),
|
||||
$i18n->get('bounce message')
|
||||
)
|
||||
. '</th></tr>';
|
||||
while ( my $values = $sth->arrayRef ) {
|
||||
$output .= '<tr><td>'. join( '</td><td>', @$values ) . '</td></tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,14 @@ our $I18N = {
|
|||
'generate mailing' => {
|
||||
message => 'Genereer mailing',
|
||||
},
|
||||
|
||||
'bounce reason' => {
|
||||
message => 'Laatste bounce oorzaak',
|
||||
},
|
||||
|
||||
'bounce message' => {
|
||||
message => 'Laatste bounce omschrijving',
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,14 @@ our $I18N = {
|
|||
'generate mailing' => {
|
||||
message => 'Generate mailing',
|
||||
},
|
||||
|
||||
'bounce reason' => {
|
||||
message => 'Latest bounce reason',
|
||||
},
|
||||
|
||||
'bounce message' => {
|
||||
message => 'Latest bounce message',
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ addSpecialStateTable( $session );
|
|||
addListNameColumn( $session );
|
||||
addRegistrationSteps( $session );
|
||||
addConfirmationTemplateColumn( $session );
|
||||
addSentToIndex( $session );
|
||||
|
||||
finish($session);
|
||||
|
||||
|
|
@ -63,6 +64,17 @@ sub addConfirmationTemplateColumn {
|
|||
'WUk-wEhGiF8dcEogrJfrfg',
|
||||
]
|
||||
);
|
||||
|
||||
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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue