From 38dce48b716c3f6fc1561b976d98eee94af778b3 Mon Sep 17 00:00:00 2001 From: Sam Pearson Date: Thu, 14 May 2020 10:18:16 +0100 Subject: Include updates in failure summary report. This includes details of any failing updates in the summary script. --- perllib/Open311/PostServiceRequestUpdates.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'perllib/Open311/PostServiceRequestUpdates.pm') 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; -- cgit v1.2.3 From 4b780de3e34128a4581dbc4daead30be00ceadb4 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 23 Jun 2020 16:30:29 +0100 Subject: [Open311] Use devolved data on update sending. --- perllib/Open311/PostServiceRequestUpdates.pm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'perllib/Open311/PostServiceRequestUpdates.pm') diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm index 68823343c..d7345ea4d 100755 --- a/perllib/Open311/PostServiceRequestUpdates.pm +++ b/perllib/Open311/PostServiceRequestUpdates.pm @@ -14,14 +14,12 @@ use Open311; use constant SEND_METHOD_OPEN311 => 'Open311'; has verbose => ( is => 'ro', default => 0 ); -has current_open311 => ( is => 'rw' ); sub send { my $self = shift; my $bodies = $self->fetch_bodies; foreach my $body (values %$bodies) { - $self->construct_open311($body); $self->process_body($body); } } @@ -41,18 +39,25 @@ sub fetch_bodies { } sub construct_open311 { - my ($self, $body) = @_; - my $o = Open311->new($self->open311_params($body)); - $self->current_open311($o); + my ($self, $body, $comment) = @_; + my $o = Open311->new($self->open311_params($body, $comment)); + return $o; } sub open311_params { - my ($self, $body) = @_; + my ($self, $body, $comment) = @_; + + my $conf = $body; + if ($comment) { + my $cobrand_logged = $comment->get_cobrand_logged; + my $sender = $cobrand_logged->get_body_sender($body, $comment->problem->category); + $conf = $sender->{config}; + } my %open311_conf = ( - endpoint => $body->endpoint, - jurisdiction => $body->jurisdiction, - api_key => $body->api_key, + endpoint => $conf->endpoint, + jurisdiction => $conf->jurisdiction, + api_key => $conf->api_key, extended_statuses => $body->send_extended_statuses, fixmystreet_body => $body, ); @@ -119,7 +124,7 @@ sub process_update { return; } - my $o = $self->current_open311; + my $o = $self->construct_open311($body, $comment); $cobrand->call_hook(open311_pre_send => $comment, $o); -- cgit v1.2.3 From 53b9f82cbb7fe81484b8bbf434f0b0acd925b454 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 11 May 2020 12:43:02 +0100 Subject: [Hackney] Special destination handling. --- perllib/Open311/PostServiceRequestUpdates.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/Open311/PostServiceRequestUpdates.pm') diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm index d7345ea4d..a31bca8f7 100755 --- a/perllib/Open311/PostServiceRequestUpdates.pm +++ b/perllib/Open311/PostServiceRequestUpdates.pm @@ -50,7 +50,7 @@ sub open311_params { my $conf = $body; if ($comment) { my $cobrand_logged = $comment->get_cobrand_logged; - my $sender = $cobrand_logged->get_body_sender($body, $comment->problem->category); + my $sender = $cobrand_logged->get_body_sender($body, $comment->problem); $conf = $sender->{config}; } -- cgit v1.2.3 From a86acd036ad52a15ee3cf546f7f496f212be3cf5 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 23 Jan 2020 16:01:57 +0000 Subject: [Oxfordshire] include asset id in open311 description --- perllib/Open311/PostServiceRequestUpdates.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/Open311/PostServiceRequestUpdates.pm') diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm index a31bca8f7..b9aa9ed50 100755 --- a/perllib/Open311/PostServiceRequestUpdates.pm +++ b/perllib/Open311/PostServiceRequestUpdates.pm @@ -126,7 +126,7 @@ sub process_update { my $o = $self->construct_open311($body, $comment); - $cobrand->call_hook(open311_pre_send => $comment, $o); + $cobrand->call_hook(open311_pre_send_updates => $comment); my $id = $o->post_service_request_update( $comment ); -- cgit v1.2.3