From f19e3712c1aa51777fa3b78b4cb5b2e6f6b22e82 Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Wed, 4 Dec 2024 16:26:01 +0000 Subject: [PATCH 1/2] [N/land] Pass category & group updates to Alloy --- perllib/FixMyStreet/Cobrand/Northumberland.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/perllib/FixMyStreet/Cobrand/Northumberland.pm b/perllib/FixMyStreet/Cobrand/Northumberland.pm index 5d621cbacd3..a8a74332eb2 100644 --- a/perllib/FixMyStreet/Cobrand/Northumberland.pm +++ b/perllib/FixMyStreet/Cobrand/Northumberland.pm @@ -248,6 +248,8 @@ extra_metadata) to Alloy, as an 'extra_details' attribute. We pass the name and email address of the user assigned to the report (the user who has shortlisted the report). +We pass any category change. + =cut sub open311_munge_update_params { @@ -264,6 +266,15 @@ sub open311_munge_update_params { = $assigned_to ? $assigned_to->email : ''; + + if ( $comment->text =~ /Category changed/ ) { + my $service_code = $p->contact->email; + my $category_group = $p->get_extra_metadata('group'); + + $params->{service_code} = $service_code; + $params->{'attribute[group]'} = $category_group + if $category_group; + } } 1; From 09ebd760ab48819dc63044ca105e4c85fe06c250 Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Wed, 4 Dec 2024 16:26:38 +0000 Subject: [PATCH 2/2] [N/land] Fetch category & group updates from Alloy --- perllib/Open311/UpdatesBase.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/perllib/Open311/UpdatesBase.pm b/perllib/Open311/UpdatesBase.pm index 24dc99cf11c..556e764d7b3 100644 --- a/perllib/Open311/UpdatesBase.pm +++ b/perllib/Open311/UpdatesBase.pm @@ -226,6 +226,18 @@ sub _process_update { $request->{extras}{detailed_information} ) : $p->unset_extra_metadata('detailed_information'); } + + # Category & group + # TODO Do we want to check that category and group match? + if ( my $category = $request->{extras}{category} ) { + my $contact + = $body->contacts->search( { category => $category } )->first; + $p->category($category) if $contact; + } + + if ( my $group = $request->{extras}{group} ) { + $p->set_extra_metadata( group => $group ); + } } my $comment = $self->schema->resultset('Comment')->new(