From c0a7d8a062518292c798fe6d5f0e6b0d21fee7d0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 6 Feb 2023 19:19:49 +0100 Subject: hafas backend: show shortest station name in title --- lib/DBInfoscreen/Controller/Stationboard.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/DBInfoscreen/Controller/Stationboard.pm') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index aa301fb..e708305 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -472,6 +472,12 @@ sub handle_request { ( $status->station ? $status->station->{name} : $station ), }; + if ( $status->station and $status->station->{names} ) { + $data->{station_name} + = List::Util::reduce { length($a) < length($b) ? $a : $b } + @{ $status->station->{names} }; + } + if ( not @{ $data->{results} } and $template eq 'json' ) { $self->handle_no_results_json( $station, $data, $api_version ); return; -- cgit v1.2.3