diff options
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r-- | lib/DBInfoscreen.pm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index ed81638..b04fb03 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -1,4 +1,5 @@ package DBInfoscreen; + # Copyright (C) 2011-2020 Daniel Friesel # # SPDX-License-Identifier: BSD-2-Clause @@ -7,6 +8,7 @@ use Mojo::Base 'Mojolicious'; use Cache::File; use DBInfoscreen::Helper::HAFAS; +use DBInfoscreen::Helper::Marudor; use DBInfoscreen::Helper::Wagonorder; use File::Slurp qw(read_file); use JSON; @@ -114,6 +116,20 @@ sub startup { ); $self->helper( + marudor => sub { + my ($self) = @_; + state $hafas = DBInfoscreen::Helper::Marudor->new( + log => $self->app->log, + main_cache => $self->app->cache_iris_main, + realtime_cache => $self->app->cache_iris_rt, + root_url => $self->url_for('/')->to_abs, + user_agent => $self->ua, + version => $VERSION, + ); + } + ); + + $self->helper( wagonorder => sub { my ($self) = @_; state $hafas = DBInfoscreen::Helper::Wagonorder->new( @@ -316,6 +332,35 @@ sub startup { ); $self->helper( + 'utilization_icon' => sub { + my ( $self, $utilization ) = @_; + my ( $first, $second ) = @{ $utilization // [ 0, 0 ] }; + my $sum = ( $first + $second ) / 2; + + my @symbols + = ( + qw(hourglass_empty person_outline people priority_high not_interested) + ); + my $text = 'Auslastung unbekannt'; + + if ( $sum > 3.5 ) { + $text = 'Zug ist ausgebucht'; + } + elsif ( $sum >= 2.5 ) { + $text = 'Sehr hohe Auslastung'; + } + elsif ( $sum >= 1.5 ) { + $text = 'Hohe Auslastung'; + } + elsif ( $sum >= 1 ) { + $text = 'Geringe Auslastung'; + } + + return ( $text, $symbols[$first], $symbols[$second] ); + } + ); + + $self->helper( 'numeric_platform_part' => sub { my ( $self, $platform ) = @_; |