aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Nearby.pm8
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm8
-rw-r--r--perllib/FixMyStreet/Map.pm28
3 files changed, 31 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
index 06aca26db..a0ccb8a6d 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
@@ -5,11 +5,15 @@ use strict;
use warnings;
sub nearby {
- my ( $rs, $c, $dist, $ids, $limit, $mid_lat, $mid_lon, $interval, $category ) = @_;
+ my ( $rs, $c, $dist, $ids, $limit, $mid_lat, $mid_lon, $interval, $category, $states ) = @_;
+
+ unless ( $states ) {
+ $states = FixMyStreet::DB::Result::Problem->visible_states();
+ }
my $params = {
non_public => 0,
- state => [ FixMyStreet::DB::Result::Problem::visible_states() ],
+ state => [ keys %$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 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 },
};
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 2bc37ad0a..2606fd9a4 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -55,7 +55,7 @@ sub display_map {
}
sub map_features {
- my ( $c, $lat, $lon, $interval, $category ) = @_;
+ my ( $c, $lat, $lon, $interval, $category, $states ) = @_;
# TODO - be smarter about calculating the surrounding square
# use deltas that are roughly 500m in the UK - so we get a 1 sq km search box
@@ -65,12 +65,12 @@ sub map_features {
$c, $lat, $lon,
$lon - $lon_delta, $lat - $lat_delta,
$lon + $lon_delta, $lat + $lat_delta,
- $interval, $category
+ $interval, $category, $states
);
}
sub map_features_bounds {
- my ( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category ) = @_;
+ my ( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category, $states ) = @_;
my $lat = ( $max_lat + $min_lat ) / 2;
my $lon = ( $max_lon + $min_lon ) / 2;
@@ -78,20 +78,21 @@ sub map_features_bounds {
$c, $lat, $lon,
$min_lon, $min_lat,
$max_lon, $max_lat,
- $interval, $category
+ $interval, $category,
+ $states
);
}
sub _map_features {
- my ( $c, $lat, $lon, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category ) = @_;
+ my ( $c, $lat, $lon, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category, $states ) = @_;
# list of problems around map can be limited, but should show all pins
my $around_limit = $c->cobrand->on_map_list_limit || undef;
my @around_args = ( $min_lat, $max_lat, $min_lon, $max_lon, $interval );
- my $around_map = $c->cobrand->problems->around_map( @around_args, undef, $category );
+ my $around_map = $c->cobrand->problems->around_map( @around_args, undef, $category, $states );
my $around_map_list = $around_limit
- ? $c->cobrand->problems->around_map( @around_args, $around_limit, $category )
+ ? $c->cobrand->problems->around_map( @around_args, $around_limit, $category, $states )
: $around_map;
my $dist;
@@ -105,7 +106,7 @@ sub _map_features {
my $limit = 20;
my @ids = map { $_->id } @$around_map_list;
my $nearby = $c->model('DB::Nearby')->nearby(
- $c, $dist, \@ids, $limit, $lat, $lon, $interval, $category
+ $c, $dist, \@ids, $limit, $lat, $lon, $interval, $category, $states
);
return ( $around_map, $around_map_list, $nearby, $dist );
@@ -118,8 +119,17 @@ sub map_pins {
my ( $min_lon, $min_lat, $max_lon, $max_lat ) = split /,/, $bbox;
my $category = $c->req->param('category');
+ # Filter reports by status, if present in query params
+ my $status = $c->req->param('status') || '';
+ my $states;
+ if ( $status eq 'open' ) {
+ $states = FixMyStreet::DB::Result::Problem->open_states();
+ } elsif ( $status eq 'fixed' ) {
+ $states = FixMyStreet::DB::Result::Problem->fixed_states();
+ }
+
my ( $around_map, $around_map_list, $nearby, $dist ) =
- FixMyStreet::Map::map_features_bounds( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category );
+ FixMyStreet::Map::map_features_bounds( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category, $states );
# create a list of all the pins
my @pins = map {