diff options
author | matthew <matthew> | 2007-05-08 18:16:34 +0000 |
---|---|---|
committer | matthew <matthew> | 2007-05-08 18:16:34 +0000 |
commit | 251d80fb7b2c14d23ea005d7277f4fefc34282a6 (patch) | |
tree | f463efac5e1ffd6fb441971d680d311779024324 | |
parent | 8a17fba62dad81bbfe7a7f763d1c29bee66b8318 (diff) |
Add questionnaire to cron.
-rwxr-xr-x | bin/send-questionnaires | 10 | ||||
-rw-r--r-- | conf/crontab.ugly | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/bin/send-questionnaires b/bin/send-questionnaires index a6a865dca..a13ab4faa 100755 --- a/bin/send-questionnaires +++ b/bin/send-questionnaires @@ -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-questionnaires,v 1.3 2007-05-04 15:57:43 matthew Exp $ +# $Id: send-questionnaires,v 1.4 2007-05-08 18:16:34 matthew Exp $ use strict; require 5.8.0; @@ -73,7 +73,8 @@ foreach my $row (@$unsent) { values (?, ?, ms_current_timestamp())', {}, $id, $row->{id}); dbh()->do("update problem set send_questionnaire = 'f' where id=?", {}, $row->{id}); - $h{url} = mySociety::Config::get('BASE_URL') . '/Q/' . mySociety::AuthToken::store('questionnaire', $id); + my $token = mySociety::AuthToken::store('questionnaire', $id); + $h{url} = mySociety::Config::get('BASE_URL') . '/Q/' . $token; my $email = mySociety::Email::construct_email({ _template_ => $template, @@ -82,16 +83,19 @@ foreach my $row (@$unsent) { From => [ mySociety::Config::get('CONTACT_EMAIL'), 'Neighbourhood Fix-It' ], }); + print "Sending questionnaire $id, problem $row->{id}, token $token to $row->{email}\n" if $verbose; + my $result; if ($nomail) { $result = -1; - print $email; } else { $result = mySociety::EmailUtil::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $row->{email}); } if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) { + print " ...success\n" if $verbose; dbh()->commit(); } else { + print " ...failed\n" if $verbose; dbh()->rollback(); } } diff --git a/conf/crontab.ugly b/conf/crontab.ugly index 5306194fc..f6776cdb8 100644 --- a/conf/crontab.ugly +++ b/conf/crontab.ugly @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org/ # -# $Id: crontab.ugly,v 1.7 2007-04-20 11:57:47 matthew Exp $ +# $Id: crontab.ugly,v 1.8 2007-05-08 18:16:35 matthew Exp $ PATH=/usr/local/bin:/usr/bin:/bin !!(* if ($vhost eq "matthew.bci.mysociety.org") { *)!! @@ -16,4 +16,5 @@ MAILTO=team@neighbourhoodfixit.com */5 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports || echo "stalled?" 3 9,12,15,18 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-reports --verbose" || echo "stalled?" 2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-alerts || echo "stalled?" +0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock /data/vhost/!!(*= $vhost *)!!/mysociety/bci/bin/send-questionnaires || echo "stalled?" |