diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 50 | ||||
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 14 |
2 files changed, 49 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 9ae040acc..a72a8fd23 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -186,10 +186,12 @@ HASHREF. sub open_states { my $states = { - 'confirmed' => 1, - 'investigating' => 1, - 'planned' => 1, - 'in progress' => 1, + 'confirmed' => 1, + 'investigating' => 1, + 'planned' => 1, + 'in progress' => 1, + 'in progress' => 1, + 'action scheduled' => 1, }; return wantarray ? keys %{$states} : $states; @@ -227,7 +229,10 @@ HASHREF. sub closed_states { my $states = { - 'closed' => 1, + 'closed' => 1, + 'unable to fix' => 1, + 'not councils responsibility' => 1, + 'duplicate' => 1, }; return wantarray ? keys %{$states} : $states; @@ -246,14 +251,33 @@ HASHREF. sub visible_states { my $states = { - 'confirmed' => 1, - 'planned' => 1, - 'investigating' => 1, - 'in progress' => 1, - 'fixed' => 1, - 'fixed - council' => 1, - 'fixed - user' => 1, - 'closed' => 1, + 'confirmed' => 1, + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'action scheduled' => 1, + 'fixed' => 1, + 'fixed - council' => 1, + 'fixed - user' => 1, + 'unable to fix' => 1, + 'not councils responsibility' => 1, + 'duplicate' => 1, + 'closed' => 1, + }; + + return wantarray ? keys %{$states} : $states; +} + +sub council_states { + my $states = { + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'action scheduled' => 1, + 'fixed - council' => 1, + 'unable to fix' => 1, + 'not councils responsibility' => 1, + 'duplicate' => 1, }; return wantarray ? keys %{$states} : $states; diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index c30d05b22..2af128ec7 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -96,12 +96,22 @@ sub update_comments { # do not change the status of the problem as it's # tricky to determine the right thing to do. if ( $comment->created_local > $p->lastupdate_local ) { - if ( $p->is_open and lc($request->{status}) eq 'closed' ) { + my $incoming_status = lc( $request->{status} ); + my $internal_status = $incoming_status; + $internal_status =~ s/_/ /g; + if ( $p->is_open and ( $incoming_status eq 'closed' or $incoming_status eq 'fixed' ) ) { $p->state( 'fixed - council' ); $comment->problem_state( 'fixed - council' ); - } elsif ( ( $p->is_closed || $p->is_fixed ) and lc($request->{status}) eq 'open' ) { + } elsif ( ( $p->is_closed || $p->is_fixed ) and ( + $incoming_status eq 'open' or FixMyStreet::DB::Result::Problem->open_states()->{ $internal_status } + ) ) { $p->state( 'confirmed' ); $comment->problem_state( 'confirmed' ); + } else { + if ( FixMyStreet::DB::Result::Problem->council_states()->{ $internal_status } ) { + $p->state( $internal_status ); + $comment->problem_state( $internal_status ); + } } } |