aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2019-02-27 10:31:50 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-12 16:13:00 +0000
commit2af88a4986b5fc951bdef0586f487735789d36d8 (patch)
treeab23777d497b9fb76674eec7f1c9e43db389bb6b /perllib
parent7aab45bffaab6c5bd7c50acef7dc5bce6f233bc1 (diff)
[open311] optionally use fixmystreet_id to match update to problem
If an update has a fixmystreet_id field then use the contents of that in preference to the external_id field to match an update to a problem. This handles the case where a report in a third party system passes through different types (eg inspection and defect), resulting in the external id changing. In this case it is sometimes possible to include the fixmystreet id in each type and hence use that to match things up at the fixmystreet side.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm14
1 files changed, 12 insertions, 2 deletions
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";
}
}