Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions perllib/Open311/Endpoint/Integration/AlloyV2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,7 @@ sub _get_inspection_updates_design {

$args{extras} = { %{$args{extras}}, %$assigned_to_user } if $assigned_to_user;

if ( my $extra_details_code = $mapping->{extra_details} ) {
$args{extras}{detailed_information}
= $attributes->{$extra_details_code} // '';
}
$self->_add_extra_details($mapping->{extra_details}, $attributes, $args{extras}) if $mapping->{extra_details};
}

$self->_apply_extra_attributes($mapping->{extra_attributes}, $attributes, $args{extras});
Expand All @@ -848,6 +845,36 @@ sub _get_inspection_updates_design {
return (\@updates, \%items_by_id);
}

=head2 _add_extra_details

Adds a 'detailed_information' key to the 'extra' hash of an update which
will be passed to FMS for the value to be added to the
detailed_information on the report for staff only visiblility

=cut

sub _add_extra_details {
my ($self, $extra_details_code, $attributes, $extras) = @_;

my @fields;
if (ref $extra_details_code eq 'ARRAY') {
@fields = @{$extra_details_code};
} else {
push @fields, $extra_details_code;
}

$extras->{detailed_information} = '';
my $loop;
for my $field (@fields) {
if ($loop && $attributes->{$field}) {
$extras->{detailed_information} .= "\n" . $attributes->{$field};
} elsif ($attributes->{$field}) {
$extras->{detailed_information} = $attributes->{$field};
};
$loop++;
}
}

sub _skip_inspection_update { }

sub get_assigned_to_users {
Expand Down Expand Up @@ -976,6 +1003,7 @@ sub _get_defect_updates_resource {
extras => { latest_data_only => 1 },
);

$self->_add_extra_details($mapping->{extra_details}, $attributes, $args{extras}) if $mapping->{extra_details};
$self->_apply_extra_attributes($extra_mapping, $attributes, $args{extras});

push @updates, Open311::Endpoint::Service::Request::Update::mySociety->new( %args );
Expand Down
2 changes: 2 additions & 0 deletions t/open311/endpoint/dumfries_alloy.t
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ subtest 'defect updates include priority from extra_attributes' => sub {
is $defect_update->{status}, 'planned', 'Defect status is planned';
is $defect_update->{extras}{priority}, '3 - 60 Working Days', 'Defect update includes priority from extra_attributes';
is $defect_update->{extras}{latest_data_only}, 1, 'latest_data_only flag present';
is $defect_update->{extras}{detailed_information}, 'Inspector notes pothole in large category
Outcome notes fixed after a delay due to flooding of road', 'detailed_information added';
};

# See also t/open311/endpoint/alloy_deferred_work.t for async inspection upload tests.
Expand Down
3 changes: 3 additions & 0 deletions t/open311/endpoint/dumfries_alloy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ defect_resource_name:
defect_attribute_mapping:
requested_datetime: attributes_defectsReportedDate
status: attributes_defectsStatus
extra_details:
- attributes_defectsInspectorsNotes
- attributes_defectsOutcomeNotes
extra_attributes:
priority:
- root.attributes_defectTriagePriority.attributes_itemsTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
{
"attributeCode": "attributes_defectsReportedDate",
"value": "2025-12-25T10:00:00.000Z"
},
{
"attributeCode": "attributes_defectsInspectorsNotes",
"value": "Inspector notes pothole in large category"
},
{
"attributeCode": "attributes_defectsOutcomeNotes",
"value": "Outcome notes fixed after a delay due to flooding of road"
}
],
"signature": "sig123"
Expand Down
Loading