diff options
author | Dave Arter <davea@mysociety.org> | 2015-06-30 11:03:20 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-06-30 11:03:20 +0100 |
commit | bff57817b0a8d9d2ab8ceeecbcba17f259d4ac1a (patch) | |
tree | a2a755e57e92c3991c3681ae13d74347ddf0fb9c /perllib/FixMyStreet/DB/ResultSet/Problem.pm | |
parent | 1df64a30dd0939d8d9b8b1854f7f7e421d9b20ab (diff) | |
parent | b2c41d9b9ac0444565cdc8b6dbbaeedf759185ba (diff) |
Merge branch 'report-filtering-on-map'
This branch allows the map pages to be filtered by report category and
status with the 'filter_category' and 'status' GET parameters.
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 7a50a3146..7885c28b3 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -131,20 +131,25 @@ sub _recent { # Problems around a location sub around_map { - my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit ) = @_; + my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit, $category, $states ) = @_; my $attr = { order_by => { -desc => 'created' }, }; $attr->{rows} = $limit if $limit; + unless ( $states ) { + $states = FixMyStreet::DB::Result::Problem->visible_states(); + } + my $q = { non_public => 0, - state => [ FixMyStreet::DB::Result::Problem->visible_states() ], + state => [ keys %$states ], latitude => { '>=', $min_lat, '<', $max_lat }, longitude => { '>=', $min_lon, '<', $max_lon }, }; $q->{'current_timestamp - lastupdate'} = { '<', \"'$interval'::interval" } if $interval; + $q->{category} = $category if $category; my @problems = mySociety::Locale::in_gb_locale { $rs->search( $q, $attr )->all }; return \@problems; |