diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-10-29 15:25:31 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-10-29 15:25:31 +0200 |
commit | 148cf58c871ae28cfe3b2bcd806375f43f7791e7 (patch) | |
tree | 43e39ea2b595c448babbec65d5f4533fb56b3a9c /lib/DBInfoscreen/Helper | |
parent | daa8cc5a72bd10d732912595bf0ca2ad3bf167c4 (diff) |
Use HAFAS utilization directly
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r-- | lib/DBInfoscreen/Helper/HAFAS.pm | 1 | ||||
-rw-r--r-- | lib/DBInfoscreen/Helper/Marudor.pm | 54 |
2 files changed, 1 insertions, 54 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index b02deea..2fb088a 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -362,6 +362,7 @@ sub get_route_timestamps_p { rt_dep => $stop->{rt_dep}, arr_delay => $stop->{arr_delay}, dep_delay => $stop->{dep_delay}, + load => $stop->{load}, isCancelled => ( ( $stop->{arr_cancelled} or not $stop->{sched_arr} ) and diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm index 15955a3..352829b 100644 --- a/lib/DBInfoscreen/Helper/Marudor.pm +++ b/lib/DBInfoscreen/Helper/Marudor.pm @@ -116,58 +116,4 @@ sub get_efa_occupancy { return $promise; } -sub get_train_utilization { - my ( $self, %opt ) = @_; - - my $promise = Mojo::Promise->new; - my $train = $opt{train}; - - if ( not $train->sched_departure ) { - $promise->reject("train has no departure"); - return $promise; - } - - my $train_no = $train->train_no; - my $this_station = $train->station; - my @route = $train->route_post; - my $next_station; - my $dep = $train->sched_departure->iso8601; - - if ( @route > 1 ) { - $next_station = $route[1]; - } - else { - $next_station = $route[0]; - } - - if ( not $next_station ) { - $promise->reject("train has no next_station"); - return $promise; - } - - $this_station - = url_escape( encode( 'utf-8', decode( 'iso-8859-15', $this_station ) ) ); - $next_station - = url_escape( encode( 'utf-8', decode( 'iso-8859-15', $next_station ) ) ); - - $self->get_json_p( $self->{realtime_cache}, -"https://bahn.expert/api/hafas/v2/auslastung/${this_station}/${next_station}/${train_no}/${dep}" - )->then( - sub { - my ($utilization_json) = @_; - - $promise->resolve( $utilization_json->{first}, - $utilization_json->{second} ); - return; - } - )->catch( - sub { - $promise->reject; - return; - } - )->wait; - - return $promise; -} - 1; |