aboutsummaryrefslogtreecommitdiffstats
path: root/bin/open311-update-reports
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-08-11 11:55:49 +0100
committerStruan Donald <struan@exo.org.uk>2011-08-11 11:55:49 +0100
commitbc6fb03e66c94de36d0aac19179dd187b2ec6583 (patch)
treed2c2dc3877143549ea6cf834fa3a911a743ce9f4 /bin/open311-update-reports
parentb8942045bbd4f6ce6a6969522552ef2318b0c6fc (diff)
some rudimentary checks to make sure we do not put in updates that are older than current state in FMS
Diffstat (limited to 'bin/open311-update-reports')
-rw-r--r--bin/open311-update-reports16
1 files changed, 15 insertions, 1 deletions
diff --git a/bin/open311-update-reports b/bin/open311-update-reports
index 079a3390c..9d6d78282 100644
--- a/bin/open311-update-reports
+++ b/bin/open311-update-reports
@@ -8,7 +8,7 @@ use FixMyStreet::App;
# FIXME - make this configurable and/or better
my $system_user = FixMyStreet::App->model('DB::User')->find_or_create(
{
- email => $c->conf('CONTACT_EMAIL'),
+ email => FixMyStreet::App->config->{'CONTACT_EMAIL'},
name => 'System User',
}
);
@@ -58,6 +58,11 @@ while ( my $council = $council_list->next ) {
}
for my $request (@$requests) {
+ # if it's a ref that means it's an empty element
+ # however, if there's no updated date then we can't
+ # tell if it's newer that what we have so we should skip it
+ next if ref $request->{updated_datetime} || ! exists $request->{updated_datetime};
+
my $request_id = $request->{service_request_id};
my $problem =
@@ -89,6 +94,15 @@ while ( my $council = $council_list->next ) {
name => $council_details->{name},
}
);
+
+ my $w3c = DateTime::Format::W3CDTF->new;
+ my $req_time = $w3c->parse_datetime( $request->{updated_datetime} );
+
+ # update from open311 is older so skip
+ if ( $req_time < $p->lastupdate ) {
+ next;
+ }
+
if ( $request->{status} eq 'closed' ) {
if ( $p->state ne 'fixed' ) {
$p->state('fixed');