diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-11-06 12:26:26 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-11-06 12:26:26 +0000 |
commit | 53e22391a3975b2c2a9ebca8b75fab6127c767b7 (patch) | |
tree | 8c667b07a9c07dbc0c11e2d3bb003b6da9dc6db2 /perllib/FixMyStreet/Map.pm | |
parent | 91bec61612a5ad0c4ee87942dae0611a9a211243 (diff) | |
parent | 27f6a53b0be0e36ffccbabd45592ee6fddf0092a (diff) |
Merge branch 'around-and-about-pagination'
Diffstat (limited to 'perllib/FixMyStreet/Map.pm')
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index b6b618efb..e0e3c3128 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -88,23 +88,23 @@ sub map_features { $p{latitude} = ($p{max_lat} + $p{min_lat} ) / 2; } - # list of problems around map can be limited, but should show all pins - my $around_limit = $c->cobrand->on_map_list_limit || undef; - - my $on_map_all = $c->cobrand->problems_on_map->around_map( undef, %p ); - my $on_map_list = $around_limit - ? $c->cobrand->problems_on_map->around_map( $around_limit, %p ) - : $on_map_all; + $p{page} = $c->get_param('p') || 1; + my $on_map = $c->cobrand->problems_on_map->around_map( $c, %p ); + my $pager = $c->stash->{pager} = $on_map->pager; + $on_map = [ $on_map->all ]; my $dist = FixMyStreet::Gaze::get_radius_containing_population( $p{latitude}, $p{longitude} ); - my $limit = 20; - my @ids = map { $_->id } @$on_map_list; - my $nearby = $c->model('DB::Nearby')->nearby( - $c, $dist, \@ids, $limit, @p{"latitude", "longitude", "interval", "categories", "states"} - ); + my $nearby; + if (@$on_map < $pager->entries_per_page && $pager->current_page == 1) { + my $limit = 20; + my @ids = map { $_->id } @$on_map; + $nearby = $c->model('DB::Nearby')->nearby( + $c, $dist, \@ids, $limit, @p{"latitude", "longitude", "categories", "states"} + ); + } - return ( $on_map_all, $on_map_list, $nearby, $dist ); + return ( $on_map, $nearby, $dist ); } sub click_to_wgs84 { |