Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/alloy-send-group'
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 14, 2023
2 parents 300a8f2 + 40eae00 commit 748200a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 46 deletions.
47 changes: 20 additions & 27 deletions perllib/FixMyStreet/Cobrand/Hackney.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,6 @@ sub geocoder_munge_results {
$result->{display_name} =~ s/, London Borough of Hackney//;
}

=item * When sending via Open311, make sure closest address is included
=cut

around open311_extra_data_include => sub {
my ($orig, $self) = (shift, shift);
my $open311_only = $self->$orig(@_);

my ($row, $h, $contact) = @_;

# Make sure contact 'email' set correctly for Open311
if (my $split_match = $row->get_extra_metadata('split_match')) {
$row->unset_extra_metadata('split_match');
my $code = $split_match->{$contact->email};
$contact->email($code) if $code;
}

if (my $address = $row->nearest_address) {
push @$open311_only, (
{ name => 'closest_address', value => $address }
);
$h->{closest_address} = '';
}

return $open311_only;
};

=item * Hackney use OSM maps
=cut
Expand Down Expand Up @@ -260,6 +233,10 @@ sub munge_sendreport_params {
}
}

=item * When sending via Open311, make sure closest address is included
=cut

sub open311_extra_data_include {
my ($self, $row, $h, $contact) = @_;

Expand All @@ -270,6 +247,8 @@ sub open311_extra_data_include {
value => $row->detail },
{ name => 'category',
value => $row->category },
{ name => 'group',
value => $row->get_extra_metadata('group') },
];

my $title = $row->title;
Expand All @@ -292,6 +271,20 @@ sub open311_extra_data_include {
}
push @$open311_only, { name => 'title', value => $title };

# Make sure contact 'email' set correctly for Open311
if (my $split_match = $row->get_extra_metadata('split_match')) {
$row->unset_extra_metadata('split_match');
my $code = $split_match->{$contact->email};
$contact->email($code) if $code;
}

if (my $address = $row->nearest_address) {
push @$open311_only, (
{ name => 'closest_address', value => $address }
);
$h->{closest_address} = '';
}

return $open311_only;
}

Expand Down
17 changes: 0 additions & 17 deletions perllib/FixMyStreet/Cobrand/Northumberland.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,6 @@ sub munge_report_new_contacts {
}
}

sub open311_extra_data_include {
my ($self, $row, $h) = @_;

my $open311_only = [
{ name => 'report_url',
value => $h->{url} },
{ name => 'title',
value => $row->title },
{ name => 'description',
value => $row->detail },
{ name => 'category',
value => $row->category },
];

return $open311_only;
}

sub open311_title_fetched_report {
my ($self, $request) = @_;
my ($group, $category) = split(/_/, $request->{service_name});
Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Cobrand/Oxfordshire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ sub open311_extra_data_include {
value => $row->detail },
{ name => 'category',
value => $row->category },
{ name => 'group',
value => $row->get_extra_metadata('group') },
];
push @$extra, { name => 'staff_role', value => $roles } if $roles;
return $extra;
Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Roles/Open311Alloy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ sub open311_extra_data_include {
value => $row->detail },
{ name => 'category',
value => $row->category },
{ name => 'group',
value => $row->get_extra_metadata('group') },
];

return $open311_only;
Expand Down
4 changes: 2 additions & 2 deletions perllib/Open311/PopulateServiceList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ sub _get_new_groups {
return [] unless $self->_current_body_cobrand && $self->_current_body_cobrand->enable_category_groups;

my $groups = $self->_current_service->{groups} || [];
my @groups = map { Utils::trim_text($_) } @$groups;
my @groups = map { Utils::trim_text($_ || '') } @$groups;
return \@groups if @groups;

my $group = $self->_current_service->{group} || [];
$group = [] if @$group == 1 && !$group->[0]; # <group></group> becomes [undef]...
@groups = map { Utils::trim_text($_) } @$group;
@groups = map { Utils::trim_text($_ || '') } @$group;
return \@groups;
}

Expand Down
1 change: 1 addition & 0 deletions t/sendreport/open311.t
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ test_overrides hackney =>
{ name => 'title', value => 'Problem' },
{ name => 'description', value => 'A big problem' },
{ name => 'category', value => 'ZZ' },
{ name => 'group', value => undef },
{ name => 'closest_address', value => '1 Test Street, Testville, TE57 1AB' },
),
});
Expand Down

0 comments on commit 748200a

Please sign in to comment.