aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-16 16:46:04 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-16 16:46:04 +0100
commitc35ef08e4f6f51874d1ce46dce3b4895dca6fe54 (patch)
tree0f645f0747be9acaa7254e8640e904199ef82742
parent08bda4c3a6ef4e55bce01a3fa004021679b141f5 (diff)
stop using hard coded names for fixed/visible states ( work in progress )
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/EmptyHomes.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Nearby.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm10
6 files changed, 13 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 0c26220e0..b380eedfc 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -189,7 +189,7 @@ sub display_location : Private {
{
latitude => $p->latitude,
longitude => $p->longitude,
- colour => $p->state eq 'fixed' ? 'green' : 'red',
+ colour => $p->is_fixed ? 'green' : 'red',
id => $p->id,
title => $p->title,
}
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index e1983c855..3f7bd268f 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -256,7 +256,7 @@ sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
my $where = {
- state => [ 'confirmed', 'fixed' ]
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ]
};
my @extra_cols = ();
if ($c->stash->{ward}) {
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index 4a93bcb20..e8a57b117 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -112,7 +112,7 @@ sub generate_problem_banner {
my ( $self, $problem ) = @_;
my $banner = {};
- if ($problem->state eq 'fixed') {
+ if ($problem->state->is_fixed ) {
$banner->{id} = 'fixed';
$banner->{text} = _('This problem has been fixed') . '.';
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index e92846aca..d5b2f5535 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -74,7 +74,8 @@ sub email_alerts ($) {
# create problem status message for the templates
$data{state_message} =
- $row->{state} eq 'fixed'
+ # XXXXXX test this
+ FixMyStreet::DB::Result::Problem::fixed_states()->{$row->{state}}
? _("This report is currently marked as fixed.")
: _("This report is currently marked as open.");
@@ -129,11 +130,12 @@ sub email_alerts ($) {
$d = mySociety::Locale::in_gb_locale {
sprintf("%f", int($d*10+0.5)/10);
};
+ my $states = "'" . join( "', '", FixMyStreet::DB::Result::Problem::visible_states() ) . "'";
my %data = ( template => $template, data => '', alert_id => $alert->id, alert_email => $alert->user->email, lang => $alert->lang, cobrand => $alert->cobrand, cobrand_data => $alert->cobrand_data );
my $q = "select problem.id, problem.title from problem_find_nearby(?, ?, ?) as nearby, problem, users
where nearby.problem_id = problem.id
and problem.user_id = users.id
- and problem.state in ('confirmed', 'fixed')
+ and problem.state in ($states)
and problem.confirmed >= ? and problem.confirmed >= ms_current_timestamp() - '7 days'::interval
and (select whenqueued from alert_sent where alert_sent.alert_id = ? and alert_sent.parameter::integer = problem.id) is null
and users.email <> ?
diff --git a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
index 3b3a3d90b..04089096e 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
@@ -8,7 +8,7 @@ sub nearby {
my ( $rs, $c, $dist, $ids, $limit, $mid_lat, $mid_lon, $interval ) = @_;
my $params = {
- state => [ 'confirmed', 'fixed' ],
+ state => [ FixMyStreet::DB::Result::Problem::visible_states() ],
};
$params->{'current_timestamp-lastupdate'} = { '<', \"'$interval'::interval" }
if $interval;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index b1b1e00a4..4de8f2e5f 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -21,7 +21,7 @@ sub recent_fixed {
my $result = Memcached::get($key);
unless ($result) {
$result = $rs->search( {
- state => 'fixed',
+ state => [ FixMyStreet::DB::Result::Problem->fixed_states() ],
lastupdate => { '>', \"current_timestamp-'1 month'::interval" },
} )->count;
Memcached::set($key, $result, 3600);
@@ -50,7 +50,7 @@ sub recent_new {
my $result = Memcached::get($key);
unless ($result) {
$result = $rs->search( {
- state => [ 'confirmed', 'fixed' ],
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
confirmed => { '>', \"current_timestamp-'$interval'::interval" },
} )->count;
Memcached::set($key, $result, 3600);
@@ -66,7 +66,7 @@ sub recent {
my $result = Memcached::get($key);
unless ($result) {
$result = [ $rs->search( {
- state => [ 'confirmed', 'fixed' ]
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ]
}, {
columns => [ 'id', 'title' ],
order_by => { -desc => 'confirmed' },
@@ -81,7 +81,7 @@ sub recent_photos {
my ( $rs, $num, $lat, $lon, $dist ) = @_;
my $probs;
my $query = {
- state => [ 'confirmed', 'fixed' ],
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
photo => { '!=', undef },
};
my $attrs = {
@@ -125,7 +125,7 @@ sub around_map {
$attr->{rows} = $limit if $limit;
my $q = {
- state => [ 'confirmed', 'fixed' ],
+ state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
latitude => { '>=', $min_lat, '<', $max_lat },
longitude => { '>=', $min_lon, '<', $max_lon },
};