From 17563a9284665f5f9852ce9da25b94c8bb9389c2 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Mon, 8 Jul 2024 20:47:54 +0200 Subject: distinguish between 'on time' and 'no realtime data available' in rt=1 --- lib/DBInfoscreen.pm | 19 +++++++++++++++++++ lib/DBInfoscreen/Controller/Stationboard.pm | 20 ++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index 1fd3674..174fc97 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -273,6 +273,25 @@ sub startup { } ); + $self->helper( + 'get_rt_time_class' => sub { + my ( $self, $train ) = @_; + if ( $train->{has_realtime} + and not $train->{is_bit_delayed} + and not $train->{is_delayed} ) + { + return 'on-time'; + } + if ( $train->{is_bit_delayed} ) { + return 'a-bit-delayed'; + } + if ( $train->{is_delayed} ) { + return 'delayed'; + } + return q{}; + } + ); + my $r = $self->routes; $r->get('/_redirect')->to('stationboard#redirect_to_station'); diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 8e1e7df..f81074b 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1875,11 +1875,15 @@ sub handle_result { } $result->qos_messages ], }, - station => $result->station, - moreinfo => $moreinfo, - delay => $delay, + station => $result->station, + moreinfo => $moreinfo, + delay => $delay, + is_bit_delayed => + ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ), + is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ), arrival_delay => $result->arrival_delay, departure_delay => $result->departure_delay, + has_realtime => $result->has_realtime, missing_realtime => ( not $result->has_realtime and $result->start < $now ? 1 : 0 @@ -1939,9 +1943,13 @@ sub handle_result { station => $result->station, moreinfo => $moreinfo, delay => $delay, - replaced_by => [], - replacement_for => [], - route_pre => $admode eq 'arr' + is_bit_delayed => + ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ), + is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ), + has_realtime => defined $delay ? 1 : 0, + replaced_by => [], + replacement_for => [], + route_pre => $admode eq 'arr' ? [ map { $_->loc->name } $result->route ] : [], route_post => $admode eq 'arr' ? [] -- cgit v1.2.3