Fix invalid geolocation list when less than 5 unique station names are nearby
This issue was introduced in 7c7b5e9f95
and
caused the client-side javascript code to crash
This commit is contained in:
parent
780cdafcf5
commit
4ba82b51d3
1 changed files with 14 additions and 5 deletions
|
@ -140,12 +140,21 @@ sub geolocation {
|
||||||
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
|
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
|
||||||
$lat, 10 );
|
$lat, 10 );
|
||||||
@candidates = uniq_by { $_->{name} } @candidates;
|
@candidates = uniq_by { $_->{name} } @candidates;
|
||||||
|
if ( @candidates > 5 ) {
|
||||||
$self->render(
|
$self->render(
|
||||||
json => {
|
json => {
|
||||||
candidates => [ @candidates[ 0 .. 4 ] ],
|
candidates => [ @candidates[ 0 .. 4 ] ],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$self->render(
|
||||||
|
json => {
|
||||||
|
candidates => [@candidates],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub log_action {
|
sub log_action {
|
||||||
|
|
Loading…
Reference in a new issue