diff options
author | Struan Donald <struan@exo.org.uk> | 2012-11-22 19:26:18 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-11-22 19:29:01 +0000 |
commit | bacba6c39090cbd6dfbca7f89303480e1dcc742a (patch) | |
tree | e74e20d7b86fa91b86aee116fe522fcb527c5393 /perllib/Open311.pm | |
parent | 0492b90bdb2a4666f85cdab3d8f636910bbe40c1 (diff) |
use the problem_state of the comment to set the update state rather
than the state of the problem in case a second update has changed the
problem state since. On the of chance that there is no problem_state
for the comment then fall back to the state of the problem
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r-- | perllib/Open311.pm | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm index 34a9b1bfb..a34677a38 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -275,26 +275,31 @@ sub _populate_service_request_update_params { my $name = $comment->name || $comment->user->name; my ( $firstname, $lastname ) = ( $name =~ /(\w+)\.?\s+(.+)/ ); + # fall back to problem state as it's probably correct + my $state = $comment->problem_state || $comment->problem->state; + my $status = 'OPEN'; if ( $self->extended_statuses ) { - if ( $comment->problem->is_fixed ) { + if ( FixMyStreet::DB::Result::Problem->fixed_states()->{$state} ) { $status = 'FIXED'; - } elsif ( $comment->problem->state eq 'in progress' ) { + } elsif ( $state eq 'in progress' ) { $status = 'IN_PROGRESS'; - } elsif ($comment->problem->state eq 'action scheduled' - || $comment->problem->state eq 'planned' ) { + } elsif ($state eq 'action scheduled' + || $state eq 'planned' ) { $status = 'ACTION_SCHEDULED'; - } elsif ( $comment->problem->state eq 'investigating' ) { + } elsif ( $state eq 'investigating' ) { $status = 'INVESTIGATING'; - } elsif ( $comment->problem->state eq 'duplicate' ) { + } elsif ( $state eq 'duplicate' ) { $status = 'DUPLICATE'; - } elsif ( $comment->problem->state eq 'not responsible' ) { + } elsif ( $state eq 'not responsible' ) { $status = 'NOT_COUNCILS_RESPONSIBILITY'; - } elsif ( $comment->problem->state eq 'unable to fix' ) { + } elsif ( $state eq 'unable to fix' ) { $status = 'NO_FURTHER_ACTION'; } } else { - $status = $comment->problem->is_open ? 'OPEN' : 'CLOSED',; + if ( !FixMyStreet::DB::Result::Problem->open_states()->{$state} ) { + $status = 'CLOSED'; + } } my $params = { |