summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-07-20 15:42:11 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-07-20 15:42:49 +0200
commit7c7b5e9f9536f70c92d66c4055090b46e26c4c11 (patch)
treef37ce3660591c808d7f116a313b2f47330b14ac0
parentb12b5a821b68b98aad646f1931c6c9775759952c (diff)
Do not show station duplicates in geolocation list1.8.4
-rw-r--r--cpanfile1
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm6
2 files changed, 5 insertions, 2 deletions
diff --git a/cpanfile b/cpanfile
index b7b75a1..788015c 100644
--- a/cpanfile
+++ b/cpanfile
@@ -5,6 +5,7 @@ requires 'DateTime::Format::Strptime';
requires 'Email::Sender';
requires 'Geo::Distance';
requires 'Geo::Distance::XS';
+requires 'List::UtilsBy';
requires 'Mojolicious';
requires 'Mojolicious::Plugin::Authentication';
requires 'Mojo::Pg';
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index ca29594..7599dd0 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -3,6 +3,7 @@ use Mojo::Base 'Mojolicious::Controller';
use DateTime;
use DateTime::Format::Strptime;
+use List::UtilsBy qw(uniq_by);
use Travel::Status::DE::IRIS::Stations;
sub homepage {
@@ -137,10 +138,11 @@ sub geolocation {
distance => $_->[1],
}
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
- $lat, 5 );
+ $lat, 10 );
+ @candidates = uniq_by { $_->{name} } @candidates;
$self->render(
json => {
- candidates => [@candidates],
+ candidates => [ @candidates[ 0 .. 4 ] ],
}
);
}