Skip to content

Commit

Permalink
[Bromley] Include Veolia Notes in update if provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Nov 27, 2024
1 parent 2634fb7 commit d19e95a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,24 @@ sub open311_get_update_munging {
return;
}

# Fetch outgoing notes
my $echo = $self->feature('echo');
$echo = Integrations::Echo->new(%$echo);
my $event = $echo->GetEvent($request->{service_request_id}); # From the event, not the report
$echo->log($event->{Data});
my $data = Integrations::Echo::force_arrayref($event->{Data}, 'ExtensibleDatum');
my $notes = "";
foreach (@$data) {

Check warning on line 437 in perllib/FixMyStreet/Cobrand/Bromley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bromley.pm#L431-L437

Added lines #L431 - L437 were not covered by tests
$notes = $_->{Value} if $_->{DatatypeName} eq 'Veolia Notes';
}

# An update from Echo with resolution code 1252
my $code = $comment->get_extra_metadata('external_status_code') || '';
if ($code eq '1252') {
my $problem = $comment->problem;
$problem->category(REFERRED_TO_BROMLEY); # Will be LBB_RRE_FROM_VEOLIA_STREETS
$problem->state('in progress');
$comment->problem_state('in progress');

# Fetch outgoing notes
my $echo = $self->feature('echo');
$echo = Integrations::Echo->new(%$echo);
my $event = $echo->GetEvent($request->{service_request_id}); # From the event, not the report
$echo->log($event->{Data});
my $data = Integrations::Echo::force_arrayref($event->{Data}, 'ExtensibleDatum');
my $notes = "";
foreach (@$data) {
$notes = $_->{Value} if $_->{DatatypeName} eq 'Veolia Notes';
}
$problem->set_extra_metadata(handover_notes => $notes);

if (my $original_external_id = $problem->get_extra_metadata('original_bromley_external_id')) {
Expand All @@ -461,6 +461,8 @@ sub open311_get_update_munging {
$comment->problem_state(REFERRED_TO_BROMLEY);
$comment->send_state('unprocessed');

Check warning on line 462 in perllib/FixMyStreet/Cobrand/Bromley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bromley.pm#L461-L462

Added lines #L461 - L462 were not covered by tests
}
} elsif ($notes) {
$comment->text($comment->text . "\n\n" .$notes);

Check warning on line 465 in perllib/FixMyStreet/Cobrand/Bromley.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bromley.pm#L465

Added line #L465 was not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/cobrand/bromley.t
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ subtest 'redirecting of reports between backends' => sub {
is $report->state, 'fixed - council', 'A state change';
is $report->get_extra_metadata('external_status_code'), 67;
my $comment = FixMyStreet::DB->resultset("Comment")->search(undef, { order_by => { -desc => 'id' } })->first;
is $comment->text, 'Template text';
is $comment->text, "Template text\n\nOutgoing notes from Echo";
};

subtest "Echo then redirect it back to Confirm" => sub {
Expand Down

0 comments on commit d19e95a

Please sign in to comment.