aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-06-12 17:46:47 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-07-03 15:55:52 +0100
commit1b7418e2aec2ce269fde49efcff8493e4e24ad7e (patch)
tree2761dc4196b1c5f306b4e498ee633a5e939f2d9b /perllib/FixMyStreet/Map.pm
parent04e49afc9a7c10405464c62b0cfd6f6c55b286ac (diff)
Only display reports from last 6 months on around.
Add a checkbox to show older reports, plus if we get to the end of the new reports then instead of a Next button show a "show older" button that will reload the current page but with older reports also loaded. Wire it all up into the pushState code as well.
Diffstat (limited to 'perllib/FixMyStreet/Map.pm')
-rw-r--r--perllib/FixMyStreet/Map.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index f5d4c1db6..8ed0c4b37 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -92,19 +92,34 @@ sub map_features {
$p{latitude} = Utils::truncate_coordinate(($p{max_lat} + $p{min_lat} ) / 2);
}
+ my $report_age = $c->stash->{show_old_reports} ? undef : $c->cobrand->report_age;
+ $p{report_age} = $report_age;
+
$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 ];
+ if ( $c->{stash}->{show_old_reports} ) {
+ # if show_old_reports is on then there must be old reports
+ $c->stash->{num_old_reports} = 1;
+ } else {
+ $p{report_age} = undef;
+ $p{page} = 1;
+ my $older = $c->cobrand->problems_on_map->around_map( $c, %p );
+ $c->stash->{num_old_reports} = $older->pager->total_entries - $pager->total_entries;
+ }
+
my $dist = FixMyStreet::Gaze::get_radius_containing_population( $p{latitude}, $p{longitude} );
+ # if there are fewer entries than our paging limit on the map then
+ # also return nearby entries for display
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", "extra"}
+ $c, $dist, \@ids, $limit, @p{"latitude", "longitude", "categories", "states", "extra"}, $report_age
);
}