From 413f63ea43d78a6331d7794be94f95156d81ffd6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 7 Sep 2016 16:05:06 -0700 Subject: [PATCH] Renewal count by month. --- scripts/send-renewal-notices.plx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/send-renewal-notices.plx b/scripts/send-renewal-notices.plx index adf91fc..17470f5 100644 --- a/scripts/send-renewal-notices.plx +++ b/scripts/send-renewal-notices.plx @@ -45,8 +45,12 @@ foreach my $cat (@lapseCategories) { } my $lapsedCount = 0; +my %monthExpirations; foreach my $supporterId (@supporterIds) { my $expiresOn = $sp->supporterExpirationDate($supporterId); + my $expiresOnMonth = UnixDate(ParseDate($expiresOn), '%Y-%m'); + { no warnings 'uninitialized'; $monthExpirations{$expiresOnMonth}++; } + my $isLapsed = ( (not defined $expiresOn) or $expiresOn le $TODAY); my $lapsesInOneWeek = ( (defined $expiresOn) and $expiresOn le $ONE_WEEK); my $lapsesInOneMonth = ( (defined $expiresOn) and $expiresOn le $ONE_MONTH); @@ -137,6 +141,13 @@ foreach my $cat (sort { $a cmp $b } @lapseCategories) { } $emailText .= "\n"; } +$emailText .= "\n RENEWAL DUE COUNT BY MONTH\n"; +$emailText .= "\n ==========================\n"; + +foreach my $month (sort { $a cmp $b } keys %monthExpirations) { + $emailText .= sprintf("$month: %5d\n", $monthExpirations{$month}); +} + my $email = Email::MIME->create( header_str => [ To => $FROM_ADDRESS,