aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/open311-update-reports66
1 files changed, 1 insertions, 65 deletions
diff --git a/bin/open311-update-reports b/bin/open311-update-reports
index 81a0394b8..3dfb89feb 100644
--- a/bin/open311-update-reports
+++ b/bin/open311-update-reports
@@ -71,71 +71,7 @@ while ( my $council = $council_list->next ) {
->search( { external_id => $request_id, } );
if (my $p = $problem->first) {
- my ( $updated, $status_notes );
-
- if ( ! ref $request->{updated_datetime} ) {
- $updated = $request->{updated_datetime};
- }
-
- if ( ! ref $request->{status_notes} ) {
- $status_notes = $request->{status_notes};
- }
-
- my $update = FixMyStreet::App->model('DB::Comment')->new(
- {
- problem_id => $p->id,
- state => 'confirmed',
- created => $updated || \'ms_current_timestamp()',
- confirmed => \'ms_current_timestamp()',
- text => $status_notes,
- mark_open => 0,
- mark_fixed => 0,
- user => $system_user,
- anonymous => 0,
- 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');
- $update->mark_fixed(1);
-
- if ( !$status_notes ) {
-
- # FIXME - better text here
- $update->text( _('Closed by council') );
- }
-
- $p->update;
- $update->insert;
- }
- }
- # FIXME - if the council never marks as closed then
- # we will always re-open problems.
- else {
- if ( $p->state eq 'fixed' ) {
- $p->state('confirmed');
- $update->mark_open(1);
-
- if ( !$status_notes ) {
-
- # FIXME - better text here
- $update->text( _('Re-opened by council') );
- }
-
- $p->update;
- $update->insert;
- }
- }
+ $p->update_from_open311_service_request( $request, $council_details );
}
}
}