Loading lib/Travelynx/Command/work.pm +35 −0 Original line number Diff line number Diff line Loading @@ -782,6 +782,41 @@ sub run { $self->app->add_stationinfo( $uid, 0, $train->train_id, $dep, $arr ); } if ( $now->epoch - $entry->{real_arr_ts} < 900 ) { my @destinations = $self->app->journeys->get_connection_targets( uid => $uid, backend_id => $entry->{backend_id}, eva => $arr, exclude => $dep, ); $self->app->iris->get_connections_p( station => $arr, timestamp => $entry->{real_arr}, destinations => \@destinations )->then( sub { my ($suggestions) = @_; $self->app->in_transit->update_data( uid => $uid, train_id => $train_id, data => { connection_suggestions_iris => $suggestions }, ); return; } )->catch( sub { my ($err) = @_; $self->app->log->debug( "work($uid) @ DBRIS $entry->{backend_name}: get_departures_p($arr): $err" ); return; } )->wait; } } elsif ( $entry->{real_arr_ts} ) { my ( undef, $error ) = $self->app->checkout_p( Loading lib/Travelynx/Helper/DBRIS.pm +18 −2 Original line number Diff line number Diff line Loading @@ -234,8 +234,8 @@ sub grep_suggestions { ts => ( $dep->sched_dep // $dep->dep )->epoch, sort_ts => $dep->dep->epoch, is_cancelled => $dep->is_cancelled, stop_eva => $dep->{stop_eva}, maybe_line_no => $dep->{maybe_line_no}, stop_eva => $dep->stop_eva, maybe_line_no => $dep->maybe_line_no, sched_hhmm => $dep->sched_dep->strftime('%H:%M'), rt_hhmm => $dep->dep->strftime('%H:%M'), delay => $dep->delay, Loading @@ -247,11 +247,27 @@ sub grep_suggestions { if ( $dep->destination and $dep->destination eq $dest->{name} ) { if ( not $dep->is_cancelled ) { $via_count{ $dep->stop_eva } += 1; } if ( $max_per_dest and $via_count{ $dep->stop_eva } > $max_per_dest ) { next destination; } push( @suggestions, [ $dep_json, $dest ] ); next destination; } for my $via_name ( $dep->via ) { if ( $via_name eq $dest->{name} ) { if ( not $dep->is_cancelled ) { $via_count{ $dep->stop_eva } += 1; } if ( $max_per_dest and $via_count{ $dep->stop_eva } > $max_per_dest ) { next destination; } push( @suggestions, [ $dep_json, $dest ] ); next destination; } Loading lib/Travelynx/Helper/IRIS.pm +44 −0 Original line number Diff line number Diff line Loading @@ -201,17 +201,61 @@ sub get_departures_p { } } sub get_connections_p { my ( $self, %opt ) = @_; my $promise = Mojo::Promise->new; my $destinations = $opt{destinations}; $self->get_departures_p( station => $opt{station}, timestamp => $opt{timestamp}, lookbehind => 0, lookahead => 60, with_related => 1, )->then( sub { my ($res) = @_; my @suggestions = $self->grep_suggestions( results => $res->{results}, destinations => $destinations, max_per_dest => 2 ); @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} } @suggestions; $promise->resolve( \@suggestions ); return; } )->catch( sub { my ($err) = @_; $promise->reject("get_departures_p($opt{station}): $err"); return; } )->wait; return $promise; } sub grep_suggestions { my ( $self, %opt ) = @_; my $results = $opt{results}; my $destinations = $opt{destinations}; my $max_per_dest = $opt{max_per_dest}; my @suggestions; my %via_count; for my $dep ( @{$results} ) { destination: for my $dest ( @{$destinations} ) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { if ( not $dep->departure_is_cancelled ) { $via_count{ $dep->station_uic } += 1; } if ( $max_per_dest and $via_count{ $dep->station_uic } > $max_per_dest ) { next destination; } my $dep_json = { id => $dep->train_id, ts => Loading templates/_checked_in.html.ep +7 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,13 @@ % } %= include '_connections_efa', efa => $journey->{backend_name}, suggestions => \@suggestions, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_eva} : undef % } % if (my @suggestions = @{$journey->{extra_data}{connection_suggestions_iris} // []}) { <span class="card-title" style="margin-top: 2ex;">Verbindungen</span> % if ($journey->{arrival_countdown} < 0) { <p>Fahrt auswählen zum Einchecken mit Zielwahl.</p> % } %= include '_connections_iris', suggestions => \@suggestions, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_eva} : undef % } % if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} <= 0) { <p style="margin-top: 2ex;"> %= L('status.delayed-auto-checkout') Loading templates/use_history.html.ep +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ <div class="row"> <div class="col s12"> <p> Travelynx kann bei DBRIS- und EFA-Backends anhand deiner Travelynx kann bei DBRIS-, EFA- und IRIS-Backends anhand deiner vergangenen Fahrten Verbindungen zum Einchecken vorschlagen. Fährst zu z.B regelmäßig von Dortmund Hbf nach Essen Hbf, werden dir in Dortmund bevorzugt Fahrten angezeigt, die Essen passieren. Bei Loading Loading
lib/Travelynx/Command/work.pm +35 −0 Original line number Diff line number Diff line Loading @@ -782,6 +782,41 @@ sub run { $self->app->add_stationinfo( $uid, 0, $train->train_id, $dep, $arr ); } if ( $now->epoch - $entry->{real_arr_ts} < 900 ) { my @destinations = $self->app->journeys->get_connection_targets( uid => $uid, backend_id => $entry->{backend_id}, eva => $arr, exclude => $dep, ); $self->app->iris->get_connections_p( station => $arr, timestamp => $entry->{real_arr}, destinations => \@destinations )->then( sub { my ($suggestions) = @_; $self->app->in_transit->update_data( uid => $uid, train_id => $train_id, data => { connection_suggestions_iris => $suggestions }, ); return; } )->catch( sub { my ($err) = @_; $self->app->log->debug( "work($uid) @ DBRIS $entry->{backend_name}: get_departures_p($arr): $err" ); return; } )->wait; } } elsif ( $entry->{real_arr_ts} ) { my ( undef, $error ) = $self->app->checkout_p( Loading
lib/Travelynx/Helper/DBRIS.pm +18 −2 Original line number Diff line number Diff line Loading @@ -234,8 +234,8 @@ sub grep_suggestions { ts => ( $dep->sched_dep // $dep->dep )->epoch, sort_ts => $dep->dep->epoch, is_cancelled => $dep->is_cancelled, stop_eva => $dep->{stop_eva}, maybe_line_no => $dep->{maybe_line_no}, stop_eva => $dep->stop_eva, maybe_line_no => $dep->maybe_line_no, sched_hhmm => $dep->sched_dep->strftime('%H:%M'), rt_hhmm => $dep->dep->strftime('%H:%M'), delay => $dep->delay, Loading @@ -247,11 +247,27 @@ sub grep_suggestions { if ( $dep->destination and $dep->destination eq $dest->{name} ) { if ( not $dep->is_cancelled ) { $via_count{ $dep->stop_eva } += 1; } if ( $max_per_dest and $via_count{ $dep->stop_eva } > $max_per_dest ) { next destination; } push( @suggestions, [ $dep_json, $dest ] ); next destination; } for my $via_name ( $dep->via ) { if ( $via_name eq $dest->{name} ) { if ( not $dep->is_cancelled ) { $via_count{ $dep->stop_eva } += 1; } if ( $max_per_dest and $via_count{ $dep->stop_eva } > $max_per_dest ) { next destination; } push( @suggestions, [ $dep_json, $dest ] ); next destination; } Loading
lib/Travelynx/Helper/IRIS.pm +44 −0 Original line number Diff line number Diff line Loading @@ -201,17 +201,61 @@ sub get_departures_p { } } sub get_connections_p { my ( $self, %opt ) = @_; my $promise = Mojo::Promise->new; my $destinations = $opt{destinations}; $self->get_departures_p( station => $opt{station}, timestamp => $opt{timestamp}, lookbehind => 0, lookahead => 60, with_related => 1, )->then( sub { my ($res) = @_; my @suggestions = $self->grep_suggestions( results => $res->{results}, destinations => $destinations, max_per_dest => 2 ); @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} } @suggestions; $promise->resolve( \@suggestions ); return; } )->catch( sub { my ($err) = @_; $promise->reject("get_departures_p($opt{station}): $err"); return; } )->wait; return $promise; } sub grep_suggestions { my ( $self, %opt ) = @_; my $results = $opt{results}; my $destinations = $opt{destinations}; my $max_per_dest = $opt{max_per_dest}; my @suggestions; my %via_count; for my $dep ( @{$results} ) { destination: for my $dest ( @{$destinations} ) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { if ( not $dep->departure_is_cancelled ) { $via_count{ $dep->station_uic } += 1; } if ( $max_per_dest and $via_count{ $dep->station_uic } > $max_per_dest ) { next destination; } my $dep_json = { id => $dep->train_id, ts => Loading
templates/_checked_in.html.ep +7 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,13 @@ % } %= include '_connections_efa', efa => $journey->{backend_name}, suggestions => \@suggestions, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_eva} : undef % } % if (my @suggestions = @{$journey->{extra_data}{connection_suggestions_iris} // []}) { <span class="card-title" style="margin-top: 2ex;">Verbindungen</span> % if ($journey->{arrival_countdown} < 0) { <p>Fahrt auswählen zum Einchecken mit Zielwahl.</p> % } %= include '_connections_iris', suggestions => \@suggestions, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_eva} : undef % } % if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} <= 0) { <p style="margin-top: 2ex;"> %= L('status.delayed-auto-checkout') Loading
templates/use_history.html.ep +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ <div class="row"> <div class="col s12"> <p> Travelynx kann bei DBRIS- und EFA-Backends anhand deiner Travelynx kann bei DBRIS-, EFA- und IRIS-Backends anhand deiner vergangenen Fahrten Verbindungen zum Einchecken vorschlagen. Fährst zu z.B regelmäßig von Dortmund Hbf nach Essen Hbf, werden dir in Dortmund bevorzugt Fahrten angezeigt, die Essen passieren. Bei Loading