aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/PostServiceRequestUpdates.pm
diff options
context:
space:
mode:
authorSam Pearson <sam@sgp.me.uk>2020-05-14 10:18:16 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-05-26 17:27:00 +0100
commit38dce48b716c3f6fc1561b976d98eee94af778b3 (patch)
treee754a858e8df7c5edb8439345f915676cdc8044a /perllib/Open311/PostServiceRequestUpdates.pm
parent62c93922b3dfcd3489cb32cf55ab03f0e2a8b2ab (diff)
Include updates in failure summary report.
This includes details of any failing updates in the summary script.
Diffstat (limited to 'perllib/Open311/PostServiceRequestUpdates.pm')
-rwxr-xr-xperllib/Open311/PostServiceRequestUpdates.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm
index fadd063da..68823343c 100755
--- a/perllib/Open311/PostServiceRequestUpdates.pm
+++ b/perllib/Open311/PostServiceRequestUpdates.pm
@@ -141,6 +141,28 @@ sub process_update {
}
}
+sub summary_failures {
+ my $self = shift;
+ my $bodies = $self->fetch_bodies;
+ my $params = $self->construct_query(1);
+ my $u = FixMyStreet::DB->resultset("Comment")
+ ->to_body([ keys %$bodies ])
+ ->search({ "me.send_fail_count" => { '>', 0 } })
+ ->search($params, { join => "problem" });
+
+ my $base_url = FixMyStreet->config('BASE_URL');
+ my $sending_errors;
+ while (my $row = $u->next) {
+ my $url = $base_url . "/report/" . $row->problem_id;
+ $sending_errors .= "\n" . '=' x 80 . "\n\n" . "* $url, update " . $row->id . " failed "
+ . $row->send_fail_count . " times, last at " . $row->send_fail_timestamp
+ . ", reason " . $row->send_fail_reason . "\n";
+ }
+ if ($sending_errors) {
+ print '=' x 80 . "\n\n" . "The following updates failed sending:\n$sending_errors";
+ }
+}
+
sub log {
my ($self, $comment, $msg) = @_;
return unless $self->verbose;