From 8da6180bf186523af9aadd51ff5512a278f3e300 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 9 Jan 2023 19:42:41 +0100 Subject: readd ze zycles --- lib/DBInfoscreen/Controller/Stationboard.pm | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 59b7748..5c282bd 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -814,12 +814,12 @@ sub render_train { = $self->app->train_details_db->{ $departure->{train_no} }; my @cycle_from; my @cycle_to; - for my $cycle ( values %{ $departure->{composition}->{cycle} // {} } ) { - push( @cycle_from, @{ $cycle->{from} // [] } ); - push( @cycle_to, @{ $cycle->{to} // [] } ); + for my $pred ( @{ $departure->{composition}{predecessors} // [] } ) { + push( @cycle_from, $pred->[1] ); + } + for my $succ ( @{ $departure->{composition}{successors} // [] } ) { + push( @cycle_to, $succ->[1] ); } - @cycle_from = sort { $a <=> $b } uniq @cycle_from; - @cycle_to = sort { $a <=> $b } uniq @cycle_to; $departure->{cycle_from} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ]; $departure->{cycle_to} @@ -1059,6 +1059,25 @@ sub train_details { $res->{details} = [@him_details]; } + if ( $self->param('detailed') ) { + $res->{composition} + = $self->app->train_details_db->{ $res->{train_no} }; + my @cycle_from; + my @cycle_to; + for my $pred ( @{ $res->{composition}{predecessors} // [] } ) { + push( @cycle_from, $pred->[1] ); + } + for my $succ ( @{ $res->{composition}{successors} // [] } ) { + push( @cycle_to, $succ->[1] ); + } + $res->{cycle_from} + = [ map { [ $_, $self->app->train_details_db->{$_} ] } + @cycle_from ]; + $res->{cycle_to} + = [ map { [ $_, $self->app->train_details_db->{$_} ] } + @cycle_to ]; + } + $self->render( $self->param('ajax') ? '_train_details' : 'train_details', departure => $res, -- cgit v1.2.3