aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db/schema.sql8
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm50
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm14
-rw-r--r--t/open311/getservicerequestupdates.t60
4 files changed, 111 insertions, 21 deletions
diff --git a/db/schema.sql b/db/schema.sql
index 832104991..60ad8eda4 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -180,6 +180,10 @@ create table problem (
or state = 'fixed - user'
or state = 'hidden'
or state = 'partial'
+ or state = 'action scheduled'
+ or state = 'unable to fix'
+ or state = 'not councils responsibility'
+ or state = 'duplicate'
),
lang text not null default 'en-gb',
service text not null default '',
@@ -312,6 +316,10 @@ create table comment (
or problem_state = 'fixed'
or problem_state = 'fixed - council'
or problem_state = 'fixed - user'
+ or problem_state = 'action scheduled'
+ or problem_state = 'unable to fix'
+ or problem_state = 'not councils responsibility'
+ or problem_state = 'duplicate'
),
-- other fields? one to indicate whether this was written by the council
-- and should be highlighted in the display?
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 );
+ }
}
}
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 7ec8d5ae0..5ec2b5c26 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -110,19 +110,67 @@ for my $test (
description => 'This is a note',
external_id => 638344,
start_state => 'confirmed',
- close_comment => 0,
+ comment_status => 'OPEN',
mark_fixed=> 0,
mark_open => 0,
problem_state => undef,
end_state => 'confirmed',
},
{
+ desc => 'planned status changed problem status',
+ updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'PLANNED',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'planned',
+ end_state => 'planned',
+ },
+ {
+ desc => 'investigating status changes problem status',
+ updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'INVESTIGATING',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'investigating',
+ end_state => 'investigating',
+ },
+ {
+ desc => 'in progress status changes problem status',
+ updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'IN_PROGRESS',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'in progress',
+ end_state => 'in progress',
+ },
+ {
+ desc => 'action scheduled status changes problem status',
+ updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
+ description => 'This is a note',
+ external_id => 638344,
+ start_state => 'confirmed',
+ comment_status => 'ACTION_SCHEDULED',
+ mark_fixed=> 0,
+ mark_open => 0,
+ problem_state => 'action scheduled',
+ end_state => 'action scheduled',
+ },
+ {
desc => 'comment closes report',
updated_datetime => sprintf( '<updated_datetime>%s</updated_datetime>', $dt ),
description => 'This is a note',
external_id => 638344,
start_state => 'confirmed',
- close_comment => 1,
+ comment_status => 'CLOSED',
mark_fixed=> 0,
mark_open => 0,
problem_state => 'fixed - council',
@@ -134,7 +182,7 @@ for my $test (
description => 'This is a note',
external_id => 638344,
start_state => 'fixed - user',
- close_comment => 0,
+ comment_status => 'OPEN',
mark_fixed => 0,
mark_open => 0,
problem_state => 'confirmed',
@@ -146,7 +194,7 @@ for my $test (
description => 'This is a note',
external_id => 638344,
start_state => 'closed',
- close_comment => 0,
+ comment_status => 'OPEN',
mark_fixed => 0,
mark_open => 0,
problem_state => 'confirmed',
@@ -158,7 +206,7 @@ for my $test (
description => 'This is a note',
external_id => 638344,
start_state => 'closed',
- close_comment => 1,
+ comment_status => 'CLOSED',
mark_fixed => 0,
mark_open => 0,
end_state => 'closed',
@@ -169,7 +217,7 @@ for my $test (
$local_requests_xml =~ s/UPDATED_DATETIME/$test->{updated_datetime}/;
$local_requests_xml =~ s#<service_request_id>\d+</service_request_id>#<service_request_id>@{[$problem->external_id]}</service_request_id>#;
$local_requests_xml =~ s#<service_request_id_ext>\d+</service_request_id_ext>#<service_request_id_ext>@{[$problem->id]}</service_request_id_ext>#;
- $local_requests_xml =~ s#<status>\w+</status>#<status>closed</status># if $test->{close_comment};
+ $local_requests_xml =~ s#<status>\w+</status>#<status>$test->{comment_status}</status># if $test->{comment_status};
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'update.xml' => $local_requests_xml } );