diff options
-rwxr-xr-x | bin/send-reports | 14 | ||||
-rw-r--r-- | db/schema.sql | 6 |
2 files changed, 14 insertions, 6 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) { diff --git a/db/schema.sql b/db/schema.sql index d170d5f37..8e9a3f925 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -4,7 +4,7 @@ -- Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. -- Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ -- --- $Id: schema.sql,v 1.21 2007-02-08 13:59:07 matthew Exp $ +-- $Id: schema.sql,v 1.22 2007-02-08 14:21:42 matthew Exp $ -- -- secret @@ -74,6 +74,7 @@ create function ms_current_timestamp() create table contacts ( area_id integer not null, email text not null, + confirmed boolean not null, -- last editor editor text not null, @@ -91,6 +92,7 @@ create table contacts_history ( area_id integer not null, email text not null, + confirmed boolean not null, -- editor editor text not null, @@ -107,7 +109,7 @@ create table contacts_history ( create function contacts_updated() returns trigger as ' begin - insert into contacts_history (area_id, email, editor, whenedited, note) values (new.area_id, new.email, new.editor, new.whenedited, new.note); + insert into contacts_history (area_id, email, editor, whenedited, note, confirmed) values (new.area_id, new.email, new.editor, new.whenedited, new.note, new.confirmed); return new; end; ' language 'plpgsql'; |