Loading lib/Travelynx/Controller/Traveling.pm +10 −14 Original line number Diff line number Diff line Loading @@ -996,20 +996,16 @@ sub station { backend_id => 0, eva => $status->{station_eva}, ); for my $dep (@results) { destination: for my $dest (@destinations) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { push( @suggestions, [ $dep, $dest ] ); next destination; } } } } @suggestions = map { $_->[0] } sort { $a->[1] <=> $b->[1] } grep { $_->[1] >= $now - 300 } map { [ $_, $_->[0]->departure->epoch ] } @suggestions; @suggestions = $self->iris->grep_suggestions( results => \@results, destinations => \@destinations ); @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} } grep { $_->[0]{sort_ts} >= $now - 300 and $_->[0]{sort_ts} <= $now + 1800 } @suggestions; } } Loading lib/Travelynx/Helper/IRIS.pm +35 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,41 @@ sub get_departures_p { } } sub grep_suggestions { my ( $self, %opt ) = @_; my $results = $opt{results}; my $destinations = $opt{destinations}; my @suggestions; for my $dep ( @{$results} ) { destination: for my $dest ( @{$destinations} ) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { my $dep_json = { id => $dep->train_id, ts => ( $dep->sched_departure // $dep->departure )->epoch, sort_ts => $dep->departure->epoch, station_uic => $dep->station_uic, departure_is_cancelled => $dep->departure_is_cancelled, sched_hhmm => $dep->sched_departure->strftime('%H:%M'), rt_hhmm => $dep->departure->strftime('%H:%M'), departure_delay => $dep->departure_delay, platform => $dep->platform, type => $dep->type, line => $dep->line, }; push( @suggestions, [ $dep_json, $dest ] ); next destination; } } } } return @suggestions; } sub route_diff { my ( $self, $train ) = @_; my @json_route; Loading templates/_suggestions_iris.html.ep→templates/_connections_iris.html.ep +13 −13 Original line number Diff line number Diff line Loading @@ -3,37 +3,37 @@ % my ($train, $dest) = @{$res}; % my $row_class = ''; % my $link_class = 'action-checkin'; % if ($train->departure_is_cancelled) { % if ($train->{departure_is_cancelled}) { % $row_class = 'cancelled'; % $link_class = 'action-cancelled-from'; % } % if ($checkin_from) { <li class="collection-item <%= $row_class %> <%= $link_class %>" data-station="<%= $train->station_uic %>" data-train="<%= $train->train_id %>" data-ts="<%= ($train->sched_departure // $train->departure)->epoch %>" data-station="<%= $train->{station_uic} %>" data-train="<%= $train->{id} %>" data-ts="<%= $train->{ts} %>" data-dest="<%= $dest->{name} %>"> % } % else { <li class="collection-item <%= $row_class %>"> % } <a class="dep-time" href="#"> % if ($train->departure_is_cancelled) { %= $train->sched_departure->strftime('%H:%M') % if ($train->{departure_is_cancelled}) { %= $train->{sched_hhmm} % } % else { %= $train->departure->strftime('%H:%M') %= $train->{rt_hhmm} % } % if ($train->departure_delay) { %= sprintf('(%+d)', $train->departure_delay) % if ($train->{departure_delay}) { %= sprintf('(%+d)', $train->{departure_delay}) % } </a> <span class="connect-platform-wrapper"> % if ($train->platform) { <span>Gleis <%= $train->platform %></span> % if ($train->{platform}) { <span>Gleis <%= $train->{platform} %></span> % } <span class="dep-line <%= $train->type // q{} %>"> %= $train->line <span class="dep-line <%= $train->{type} // q{} %>"> %= $train->{line} </span> </span> <span class="dep-dest"> Loading templates/departures.html.ep +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ %= include '_connections_efa', suggestions => stash('suggestions'), checkin_from => $eva; % } % else { %= include '_suggestions_iris', suggestions => stash('suggestions'), checkin_from => $eva; %= include '_connections_iris', suggestions => stash('suggestions'), checkin_from => $eva; % } </div> </div> Loading Loading
lib/Travelynx/Controller/Traveling.pm +10 −14 Original line number Diff line number Diff line Loading @@ -996,20 +996,16 @@ sub station { backend_id => 0, eva => $status->{station_eva}, ); for my $dep (@results) { destination: for my $dest (@destinations) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { push( @suggestions, [ $dep, $dest ] ); next destination; } } } } @suggestions = map { $_->[0] } sort { $a->[1] <=> $b->[1] } grep { $_->[1] >= $now - 300 } map { [ $_, $_->[0]->departure->epoch ] } @suggestions; @suggestions = $self->iris->grep_suggestions( results => \@results, destinations => \@destinations ); @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} } grep { $_->[0]{sort_ts} >= $now - 300 and $_->[0]{sort_ts} <= $now + 1800 } @suggestions; } } Loading
lib/Travelynx/Helper/IRIS.pm +35 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,41 @@ sub get_departures_p { } } sub grep_suggestions { my ( $self, %opt ) = @_; my $results = $opt{results}; my $destinations = $opt{destinations}; my @suggestions; for my $dep ( @{$results} ) { destination: for my $dest ( @{$destinations} ) { for my $via_name ( $dep->route_post ) { if ( $via_name eq $dest->{name} ) { my $dep_json = { id => $dep->train_id, ts => ( $dep->sched_departure // $dep->departure )->epoch, sort_ts => $dep->departure->epoch, station_uic => $dep->station_uic, departure_is_cancelled => $dep->departure_is_cancelled, sched_hhmm => $dep->sched_departure->strftime('%H:%M'), rt_hhmm => $dep->departure->strftime('%H:%M'), departure_delay => $dep->departure_delay, platform => $dep->platform, type => $dep->type, line => $dep->line, }; push( @suggestions, [ $dep_json, $dest ] ); next destination; } } } } return @suggestions; } sub route_diff { my ( $self, $train ) = @_; my @json_route; Loading
templates/_suggestions_iris.html.ep→templates/_connections_iris.html.ep +13 −13 Original line number Diff line number Diff line Loading @@ -3,37 +3,37 @@ % my ($train, $dest) = @{$res}; % my $row_class = ''; % my $link_class = 'action-checkin'; % if ($train->departure_is_cancelled) { % if ($train->{departure_is_cancelled}) { % $row_class = 'cancelled'; % $link_class = 'action-cancelled-from'; % } % if ($checkin_from) { <li class="collection-item <%= $row_class %> <%= $link_class %>" data-station="<%= $train->station_uic %>" data-train="<%= $train->train_id %>" data-ts="<%= ($train->sched_departure // $train->departure)->epoch %>" data-station="<%= $train->{station_uic} %>" data-train="<%= $train->{id} %>" data-ts="<%= $train->{ts} %>" data-dest="<%= $dest->{name} %>"> % } % else { <li class="collection-item <%= $row_class %>"> % } <a class="dep-time" href="#"> % if ($train->departure_is_cancelled) { %= $train->sched_departure->strftime('%H:%M') % if ($train->{departure_is_cancelled}) { %= $train->{sched_hhmm} % } % else { %= $train->departure->strftime('%H:%M') %= $train->{rt_hhmm} % } % if ($train->departure_delay) { %= sprintf('(%+d)', $train->departure_delay) % if ($train->{departure_delay}) { %= sprintf('(%+d)', $train->{departure_delay}) % } </a> <span class="connect-platform-wrapper"> % if ($train->platform) { <span>Gleis <%= $train->platform %></span> % if ($train->{platform}) { <span>Gleis <%= $train->{platform} %></span> % } <span class="dep-line <%= $train->type // q{} %>"> %= $train->line <span class="dep-line <%= $train->{type} // q{} %>"> %= $train->{line} </span> </span> <span class="dep-dest"> Loading
templates/departures.html.ep +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ %= include '_connections_efa', suggestions => stash('suggestions'), checkin_from => $eva; % } % else { %= include '_suggestions_iris', suggestions => stash('suggestions'), checkin_from => $eva; %= include '_connections_iris', suggestions => stash('suggestions'), checkin_from => $eva; % } </div> </div> Loading