aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-02-20 14:08:33 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-02-25 12:19:50 +0000
commit0c8aae1ab17617f46f400bab81bb7a3b144b4a1e (patch)
tree61395979a0dad8a235a7b0c8bf505bc55acd5aef /perllib/FixMyStreet/App/Controller/Report.pm
parent66f2160d3718f049a3772f2f69f623971295f547 (diff)
Internal JSON endpoint to get reports near a point
Unused right now, but will be soon, for the duplicate suggestion UI.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm20
1 files changed, 16 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 796c2a42b..e032caa09 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -600,17 +600,29 @@ sub nearby_json :PathPart('nearby.json') :Chained('id') :Args(0) {
my ($self, $c) = @_;
my $p = $c->stash->{problem};
- my $params = {
+ $c->forward('_nearby_json', [ {
latitude => $p->latitude,
longitude => $p->longitude,
categories => [ $p->category ],
ids => [ $p->id ],
- distance => 1,
- };
+ } ]);
+}
+
+sub _nearby_json :Private {
+ my ($self, $c, $params) = @_;
# This is for the list template, this is a list on that page.
$c->stash->{page} = 'report';
+ # distance in metres
+ my $dist = $c->get_param('distance') || '';
+ $dist = 1000 unless $dist =~ /^\d+$/;
+ $dist = 1000 if $dist > 1000;
+ $params->{distance} = $dist / 1000;
+
+ my $pin_size = $c->get_param('pin_size') || '';
+ $pin_size = 'small' unless $pin_size =~ /^(mini|small|normal|big)$/;
+
$params->{extra} = $c->cobrand->call_hook('display_location_extra_params');
$params->{limit} = 5;
@@ -621,7 +633,7 @@ sub nearby_json :PathPart('nearby.json') :Chained('id') :Args(0) {
my @pins = map {
my $p = $_->pin_data($c, 'around');
[ $p->{latitude}, $p->{longitude}, $p->{colour},
- $p->{id}, $p->{title}, 'small', JSON->false
+ $p->{id}, $p->{title}, $pin_size, JSON->false
]
} @$nearby;