aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-reports
diff options
context:
space:
mode:
Diffstat (limited to 'bin/send-reports')
-rwxr-xr-xbin/send-reports14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 988e8c4b3..f8ffce8a6 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: send-reports,v 1.11 2007-02-07 09:56:15 matthew Exp $
+# $Id: send-reports,v 1.12 2007-02-08 14:21:41 matthew Exp $
use strict;
require 5.8.0;
@@ -40,16 +40,19 @@ $nomail = 1 if (@ARGV==1 && $ARGV[0] eq '--nomail');
my $unsent = dbh()->selectall_arrayref(
"SELECT id, council, title, detail, name, email, phone, used_map
- FROM problem WHERE state = 'confirmed' AND whensent IS NULL", { Slice => {} });
+ FROM problem WHERE state in ('confirmed','fixed') AND whensent IS NULL", { Slice => {} });
foreach my $row (@$unsent) {
# XXX Needs locks!
my @councils = split ',', $row->{council};
my $areas_info = mySociety::MaPit::get_voting_areas_info(\@councils);
my (@to, @recips);
+ my $all_confirmed = 1;
foreach my $council (@councils) {
my $name = $areas_info->{$council}->{name};
- my $council_email = dbh()->selectrow_array('SELECT email FROM contacts WHERE area_id=?', {}, $council);
+ my ($council_email,$confirmed) = dbh()->selectrow_array(
+ 'SELECT email,confirmed FROM contacts WHERE area_id=?', {}, $council);
next unless $council_email; # Ignore missing councils
+ $all_confirmed = 0 unless $confirmed;
push @to, [ $council_email, $name ];
push @recips, $council_email;
}
@@ -58,6 +61,10 @@ foreach my $row (@$unsent) {
print " ...but we have no contact details for any of them!\n";
next;
}
+ if (!$all_confirmed) {
+ print " ...but email addresses have not been confirmed for any of them\n";
+ next;
+ }
push @recips, mySociety::Config::get('CONTACT_EMAIL');
@@ -78,7 +85,6 @@ foreach my $row (@$unsent) {
To => \@to,
'Reply-To' => [ [ $row->{email}, $row->{name} ] ]
});
- print $email if $nomail;
my $result;
if (mySociety::Config::get('STAGING_SITE') || $nomail) {