mirror of
https://github.com/derf/travelynx
synced 2024-12-04 02:09:09 +00:00
Do not show station duplicates in geolocation list
This commit is contained in:
parent
b12b5a821b
commit
7c7b5e9f95
2 changed files with 5 additions and 2 deletions
1
cpanfile
1
cpanfile
|
@ -5,6 +5,7 @@ requires 'DateTime::Format::Strptime';
|
||||||
requires 'Email::Sender';
|
requires 'Email::Sender';
|
||||||
requires 'Geo::Distance';
|
requires 'Geo::Distance';
|
||||||
requires 'Geo::Distance::XS';
|
requires 'Geo::Distance::XS';
|
||||||
|
requires 'List::UtilsBy';
|
||||||
requires 'Mojolicious';
|
requires 'Mojolicious';
|
||||||
requires 'Mojolicious::Plugin::Authentication';
|
requires 'Mojolicious::Plugin::Authentication';
|
||||||
requires 'Mojo::Pg';
|
requires 'Mojo::Pg';
|
||||||
|
|
|
@ -3,6 +3,7 @@ use Mojo::Base 'Mojolicious::Controller';
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTime::Format::Strptime;
|
use DateTime::Format::Strptime;
|
||||||
|
use List::UtilsBy qw(uniq_by);
|
||||||
use Travel::Status::DE::IRIS::Stations;
|
use Travel::Status::DE::IRIS::Stations;
|
||||||
|
|
||||||
sub homepage {
|
sub homepage {
|
||||||
|
@ -137,10 +138,11 @@ sub geolocation {
|
||||||
distance => $_->[1],
|
distance => $_->[1],
|
||||||
}
|
}
|
||||||
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
|
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
|
||||||
$lat, 5 );
|
$lat, 10 );
|
||||||
|
@candidates = uniq_by { $_->{name} } @candidates;
|
||||||
$self->render(
|
$self->render(
|
||||||
json => {
|
json => {
|
||||||
candidates => [@candidates],
|
candidates => [ @candidates[ 0 .. 4 ] ],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue