summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-10-19 16:47:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-10-19 16:47:33 +0200
commit4ba82b51d301fff67728b8860d409d92cc11b352 (patch)
tree62a267aa8c4c0b0e9042be3f6b46f51035a5d3bc /lib/Travelynx
parent780cdafcf5e7f078a880d9875f2304f52dafbf0d (diff)
Fix invalid geolocation list when less than 5 unique station names are nearby1.9.8
This issue was introduced in 7c7b5e9f9536f70c92d66c4055090b46e26c4c11 and caused the client-side javascript code to crash
Diffstat (limited to 'lib/Travelynx')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index eebe27a..3fea24b 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -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],
+ }
+ );
+ }
}
}