From 09f94956ecd20a7aa861d0f7254189fd9373b813 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Fri, 27 Feb 2015 12:51:29 +0000 Subject: Add category filtering support to /ajax via 'category' GET param --- perllib/FixMyStreet/DB/ResultSet/Problem.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm') diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 7a50a3146..affc6b177 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -131,7 +131,7 @@ 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 ) = @_; my $attr = { order_by => { -desc => 'created' }, }; @@ -145,6 +145,7 @@ sub around_map { }; $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; -- cgit v1.2.3 From 0176b3c6918fbfa6ee22f24066d3a3d8850c8cca Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 3 Mar 2015 20:32:07 +0000 Subject: Allow /ajax to be filtered by status If present, the 'status' param can be set to 'open' or 'fixed' to display ensure only open or fixed reports respectively are included in the response. --- perllib/FixMyStreet/DB/ResultSet/Problem.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm') diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index affc6b177..7885c28b3 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -131,15 +131,19 @@ sub _recent { # Problems around a location sub around_map { - my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit, $category ) = @_; + 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 }, }; -- cgit v1.2.3