aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-08-02 09:40:33 +0100
committerStruan Donald <struan@exo.org.uk>2012-08-02 09:40:33 +0100
commit6324af77e91613e8bfe13ebde2da5f00d045cfab (patch)
treedf35a2e4de32a4d3511d84fb074a319c322b2189
parente623b599a2d5f661f8992186d5d40a32a6fba535 (diff)
A start_date and an end_date was only producing one confirmed condition
in the where clause as they were overwriting each other. This now handles start and end date explicitely to generate the correct search criteria Fixes #310
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 34e2b7cd3..14b790db8 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -319,8 +319,6 @@ sub get_requests : Private {
service_request_id => [ '=', 'id' ],
service_code => [ '=', 'category' ],
status => [ 'IN', 'state' ],
- start_date => [ '>=', 'confirmed' ],
- end_date => [ '<', 'confirmed' ],
agency_responsible => [ '~', 'council' ],
interface_used => [ '=', 'service' ],
has_photo => [ '=', 'photo' ],
@@ -365,6 +363,14 @@ sub get_requests : Private {
$criteria->{$key} = { $op, $value };
}
+ if ( $c->req->param('start_date') and $c->req->param('end_date') ) {
+ $criteria->{confirmed} = [ '-and' => { '>=', $c->req->param('start_date') }, { '<', $c->req->param('end_date') } ];
+ } elsif ( $c->req->param('start_date') ) {
+ $criteria->{confirmed} = { '>=', $c->req->param('start_date') };
+ } elsif ( $c->req->param('end_date') ) {
+ $criteria->{confirmed} = { '<', $c->req->param('end_date') };
+ }
+
if ('rss' eq $c->stash->{format}) {
$c->stash->{type} = 'new_problems';
$c->forward( '/rss/lookup_type' );