From f00f0f3d0e6c0058114dcd0e4c619920e192573b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 20 May 2024 12:33:41 +0100 Subject: [PATCH] [Brent] Add nsg mapping config. --- perllib/FixMyStreet/Cobrand/Brent.pm | 7 +++++++ t/cobrand/brent.t | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Brent.pm b/perllib/FixMyStreet/Cobrand/Brent.pm index 0c29041e92c..58c2b341c43 100644 --- a/perllib/FixMyStreet/Cobrand/Brent.pm +++ b/perllib/FixMyStreet/Cobrand/Brent.pm @@ -561,6 +561,7 @@ sub open311_update_missing_data { Reports made via the app probably won't have a NSGRef because we don't display the road layer. Instead we'll look up the closest asset from the WFS service at the point we're sending the report over Open311. +We also might need to map one value to another. =cut @@ -571,6 +572,12 @@ WFS service at the point we're sending the report over Open311. } } + my $ref = $row->get_extra_field_value('NSGRef') || ''; + my $cfg = $self->feature('area_code_mapping') || {}; + if ($cfg->{$ref}) { + $row->update_extra_field({ name => 'NSGRef', description => 'NSG Ref', value => $cfg->{$ref} }); + } + =item * Adds NSGRef from WFS service as app doesn't include road layer for Echo Same as Symology above, but different attribute name. diff --git a/t/cobrand/brent.t b/t/cobrand/brent.t index 87cd7e7654b..18f0cd60f3d 100644 --- a/t/cobrand/brent.t +++ b/t/cobrand/brent.t @@ -358,20 +358,24 @@ subtest "Open311 attribute changes" => sub { } ); $problem->update_extra_field( { name => 'UnitID', value => '234' } ); + $problem->update_extra_field( { name => 'NSGRef', value => 'BadUSRN' } ); $problem->update; FixMyStreet::override_config { ALLOWED_COBRANDS => 'brent', MAPIT_URL => 'http://mapit.uk/', STAGING_FLAGS => { send_reports => 1 }, - COBRAND_FEATURES => - { anonymous_account => { brent => 'anonymous' }, }, + COBRAND_FEATURES => { + anonymous_account => { brent => 'anonymous' }, + area_code_mapping => { brent => { BadUSRN => 'GoodUSRN' } }, + }, }, sub { FixMyStreet::Script::Reports::send(); my $req = Open311->test_req_used; my $c = CGI::Simple->new( $req->content ); is $c->param('attribute[UnitID]'), undef, 'UnitID removed from attributes'; + is $c->param('attribute[NSGRef]'), 'GoodUSRN', 'USRN updated'; like $c->param('description'), qr/ukey: 234/, 'UnitID on gully sent across in detail'; my $title = $problem->title