diff options
author | Struan Donald <struan@exo.org.uk> | 2011-08-18 13:57:16 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-08-18 13:57:16 +0100 |
commit | 01750786cc7f8d13f939eb75284f1d805673effe (patch) | |
tree | ed7595d2a3e4b0faebeba6620ff5ef93519df03f | |
parent | 3b5d561700b184c20e63111d4cbc1daab78e16c6 (diff) |
remove hard coded references to fixed
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 4 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 7 |
5 files changed, 9 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 1021f7056..677f23ceb 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -31,7 +31,7 @@ sub my : Path : Args(0) { my $pins = []; my $problems = {}; my $rs = $c->user->problems->search( { - state => [ 'confirmed', 'fixed' ], + state => [ FixMyStreet::DB::Result::Problem->visible_states() ], }, { order_by => { -desc => 'confirmed' }, rows => 50 @@ -41,7 +41,7 @@ sub my : Path : Args(0) { push @$pins, { latitude => $problem->latitude, longitude => $problem->longitude, - colour => $problem->state eq 'fixed' ? 'green' : 'red', + colour => $problem->is_fixed ? 'green' : 'red', id => $problem->id, title => $problem->title, }; diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index a8bdca7a4..7a089eb76 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -297,7 +297,7 @@ sub display : Private { pins => [ { latitude => $problem->latitude, longitude => $problem->longitude, - colour => $problem->state eq 'fixed' ? 'green' : 'red', + colour => $problem->is_fixed() ? 'green' : 'red', } ], ); } diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index bf270a3b2..f7fb5dec5 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -420,7 +420,7 @@ sub add_row { push @$pins, { latitude => $problem->{latitude}, longitude => $problem->{longitude}, - colour => $problem->{state} eq 'fixed' ? 'green' : 'red', + colour => FixMyStreet::DB::Result::Problem->fixed_states()->{$problem->{state}} ? 'green' : 'red', id => $problem->{id}, title => $problem->{title}, }; diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 26a1a1459..1ebf35652 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -75,7 +75,7 @@ sub confirm_problem : Path('/P') { $c->authenticate( { email => $problem->user->email }, 'no_password' ); $c->set_session_cookie_expire(0); - if ( $old_state eq 'confirmed' || $old_state eq 'fixed' ) { + if ( FixMyStreet::DB::Result::Problem->visible_states()->{$old_state} == 1 ) { my $report_uri = $c->uri_for( '/report', $problem->id ); $c->res->redirect($report_uri); } diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 89f17fa60..8c1f95bae 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -177,7 +177,7 @@ sub unique_users { my ( $rs ) = @_; return $rs->search( { - state => [ 'confirmed', 'fixed' ], + state => [ FixMyStreet::DB::Result::Problem->visible_states() ], }, { select => [ { count => { distinct => 'user_id' } } ], as => [ 'count' ] @@ -187,11 +187,12 @@ sub unique_users { sub categories_summary { my ( $rs ) = @_; + my $fixed_case = "case when state IN ( '" . join( "', '", FixMyStreet::DB::Result::Problem->fixed_states() ) . "' ) then 1 else null end"; my $categories = $rs->search( { - state => [ 'confirmed', 'fixed' ], + state => [ FixMyStreet::DB::Result::Problem->visible_states() ], whensent => { '<' => \"NOW() - INTERVAL '4 weeks'" }, }, { - select => [ 'category', { count => 'id' }, { count => \"case when state='fixed' then 1 else null end" } ], + select => [ 'category', { count => 'id' }, { count => \$fixed_case } ], as => [ 'category', 'c', 'fixed' ], group_by => [ 'category' ], result_class => 'DBIx::Class::ResultClass::HashRefInflator' |