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,11 +140,20 @@ sub geolocation {
|
|||
} Travel::Status::DE::IRIS::Stations::get_station_by_location( $lon,
|
||||
$lat, 10 );
|
||||
@candidates = uniq_by { $_->{name} } @candidates;
|
||||
$self->render(
|
||||
json => {
|
||||
candidates => [ @candidates[ 0 .. 4 ] ],
|
||||
}
|
||||
);
|
||||
if ( @candidates > 5 ) {
|
||||
$self->render(
|
||||
json => {
|
||||
candidates => [ @candidates[ 0 .. 4 ] ],
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->render(
|
||||
json => {
|
||||
candidates => [@candidates],
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue