aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/Bristol.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/Greenwich.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm3
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm14
-rwxr-xr-xperllib/Open311/PostServiceRequestUpdates.pm4
8 files changed, 40 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bristol.pm b/perllib/FixMyStreet/Cobrand/Bristol.pm
index 0660acc79..fa2d3fabb 100644
--- a/perllib/FixMyStreet/Cobrand/Bristol.pm
+++ b/perllib/FixMyStreet/Cobrand/Bristol.pm
@@ -75,4 +75,13 @@ sub open311_config {
$params->{always_send_email} = 1;
}
+sub open311_contact_meta_override {
+ my ($self, $service, $contact, $meta) = @_;
+
+ my %server_set = (easting => 1, northing => 1);
+ foreach (@$meta) {
+ $_->{automated} = 'server_set' if $server_set{$_->{code}};
+ }
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 2ae498b38..341fb6a30 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -252,6 +252,11 @@ sub open311_contact_meta_override {
$contact->set_extra_metadata( id_field => 'service_request_id_ext');
+ my %server_set = (easting => 1, northing => 1, service_request_id_ext => 1);
+ foreach (@$meta) {
+ $_->{automated} = 'server_set' if $server_set{$_->{code}};
+ }
+
# Lights we want to store feature ID, PROW on all categories.
push @$meta, {
code => 'prow_reference',
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 53d25cec2..785177b5e 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1182,6 +1182,7 @@ Return true if an Open311 service attribute should be a hidden field.
sub category_extra_hidden {
my ($self, $meta) = @_;
+ return 1 if ($meta->{automated} || '') eq 'hidden_field';
return 0;
}
diff --git a/perllib/FixMyStreet/Cobrand/Greenwich.pm b/perllib/FixMyStreet/Cobrand/Greenwich.pm
index 6ff30e83d..2aaa5d776 100644
--- a/perllib/FixMyStreet/Cobrand/Greenwich.pm
+++ b/perllib/FixMyStreet/Cobrand/Greenwich.pm
@@ -66,4 +66,13 @@ sub open311_config {
$row->set_extra_fields( @$extra );
}
+sub open311_contact_meta_override {
+ my ($self, $service, $contact, $meta) = @_;
+
+ my %server_set = (easting => 1, northing => 1, closest_address => 1);
+ foreach (@$meta) {
+ $_->{automated} = 'server_set' if $server_set{$_->{code}};
+ }
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index 5def2bb61..08482a0b3 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -178,14 +178,12 @@ sub open311_config {
my $extra = $row->get_extra_fields;
push @$extra, { name => 'external_id', value => $row->id };
+ push @$extra, { name => 'northing', value => $h->{northing} };
+ push @$extra, { name => 'easting', value => $h->{easting} };
if ($h->{closest_address}) {
push @$extra, { name => 'closest_address', value => "$h->{closest_address}" }
}
- if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) {
- push @$extra, { name => 'northing', value => $h->{northing} };
- push @$extra, { name => 'easting', value => $h->{easting} };
- }
$row->set_extra_fields( @$extra );
$params->{extended_description} = 'oxfordshire';
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index 1202d48a4..0eb350311 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -394,8 +394,7 @@ sub lookup_by_ref_regex {
sub category_extra_hidden {
my ($self, $meta) = @_;
return 1 if $meta->{code} eq 'usrn' || $meta->{code} eq 'asset_id';
- return 1 if $meta->{automated} eq 'hidden_field';
- return 0;
+ return $self->SUPER::category_extra_hidden($meta);
}
1;
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 1d07e7897..06b5ce321 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -91,7 +91,7 @@ sub update_comments {
# If there's no request id then we can't work out
# what problem it belongs to so just skip
- next unless $request_id;
+ next unless $request_id || $request->{fixmystreet_id};
my $comment_time = eval {
DateTime::Format::W3CDTF->parse_datetime( $request->{updated_datetime} || "" );
@@ -101,9 +101,19 @@ sub update_comments {
next if @args && ($updated lt $args[0] || $updated gt $args[1]);
my $problem;
+ my $match_field = 'external_id';
my $criteria = {
external_id => $request_id,
};
+
+ # in some cases we only have the FMS id and not the request id so use that
+ if ( $request->{fixmystreet_id} ) {
+ $criteria = {
+ id => $request->{fixmystreet_id},
+ };
+ $match_field = 'fixmystreet id';
+ }
+
$problem = $self->schema->resultset('Problem')->to_body($body)->search( $criteria );
if (my $p = $problem->first) {
@@ -198,7 +208,7 @@ sub update_comments {
# we get lots of comments that are not related to FMS issues from Lewisham so ignore those otherwise
# way too many warnings.
} elsif (FixMyStreet->config('STAGING_SITE') and $body->name !~ /Lewisham/) {
- warn "Failed to match comment to problem with external_id $request_id for " . $body->name . "\n";
+ warn "Failed to match comment to problem with $match_field $request_id for " . $body->name . "\n";
}
}
diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm
index 252f08aff..1f080b168 100755
--- a/perllib/Open311/PostServiceRequestUpdates.pm
+++ b/perllib/Open311/PostServiceRequestUpdates.pm
@@ -53,18 +53,16 @@ sub process_body {
my $o = Open311->new( $self->open311_params($body) );
- my $comments = FixMyStreet::DB->resultset('Comment')->search( {
+ my $comments = FixMyStreet::DB->resultset('Comment')->to_body($body)->search( {
'me.whensent' => undef,
'me.external_id' => undef,
'me.state' => 'confirmed',
'me.confirmed' => { '!=' => undef },
'problem.whensent' => { '!=' => undef },
'problem.external_id' => { '!=' => undef },
- 'problem.bodies_str' => { -like => '%' . $body->id . '%' },
'problem.send_method_used' => { -like => '%Open311%' },
},
{
- join => 'problem',
order_by => [ 'confirmed', 'id' ],
}
);