diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-07-01 16:35:23 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-07-01 16:35:23 +0100 |
commit | 67872ee79ba9aa4356af2cc3bacb730ef665933a (patch) | |
tree | a7fa954f8377ab3dec291b26aad595f7c91b1edb /perllib/FixMyStreet/App/Controller/JSON.pm | |
parent | 981abe759dca02f7244f48999b08cd2130bfdd65 (diff) |
Integrate #101 into new code.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/JSON.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/JSON.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm index 3a3010911..a89fb3e6c 100644 --- a/perllib/FixMyStreet/App/Controller/JSON.pm +++ b/perllib/FixMyStreet/App/Controller/JSON.pm @@ -39,6 +39,7 @@ sub problems : Local { # gather the parameters my $start_date = $c->req->param('start_date') || ''; my $end_date = $c->req->param('end_date') || ''; + my $category = $c->req->param('category') || ''; my $yyyy_mm_dd = qr{^\d{4}-\d\d-\d\d$}; if ( $start_date !~ $yyyy_mm_dd @@ -73,25 +74,29 @@ sub problems : Local { my ( $state, $date_col ); if ( $type eq 'new_problems' ) { $state = 'confirmed'; - $date_col = 'created'; + $date_col = 'confirmed'; } elsif ( $type eq 'fixed_problems' ) { $state = 'fixed'; $date_col = 'lastupdate'; } my $one_day = DateTime::Duration->new( days => 1 ); - my @problems = $c->cobrand->problems->search( { + my $query = { $date_col => { '>=' => $start_dt, '<=' => $end_dt + $one_day, }, state => $state, - }, { + }; + $query->{category} = $category if $category; + my @problems = $c->cobrand->problems->search( $query, { order_by => { -asc => 'confirmed' }, columns => [ 'id', 'title', 'council', 'category', 'detail', 'name', 'anonymous', 'confirmed', 'whensent', 'service', + 'latitude', 'longitude', 'used_map', + 'state', 'lastupdate', ] } ); |