diff options
Diffstat (limited to 'lib/Travelynx')
-rw-r--r-- | lib/Travelynx/Controller/Passengerrights.pm | 34 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 45 |
2 files changed, 43 insertions, 36 deletions
diff --git a/lib/Travelynx/Controller/Passengerrights.pm b/lib/Travelynx/Controller/Passengerrights.pm index 0170ed5..d6ed39c 100644 --- a/lib/Travelynx/Controller/Passengerrights.pm +++ b/lib/Travelynx/Controller/Passengerrights.pm @@ -53,6 +53,7 @@ sub mark_substitute_connection { my @substitute_candidates = reverse $self->get_user_travels( after => $journey->{sched_departure}->clone->subtract( hours => 1 ), before => $journey->{sched_departure}->clone->add( hours => 12 ), + with_datetime => 1, ); my ( $first_substitute, $last_substitute ); @@ -76,8 +77,7 @@ sub mark_substitute_connection { $journey->{from_substitute} = $first_substitute; $journey->{to_substitute} = $last_substitute; $journey->{substitute_delay} - = ( $last_substitute->{rt_arrival}->epoch - - $journey->{sched_arrival}->epoch ) / 60; + = ( $last_substitute->{rt_arr_ts} - $journey->{sched_ar_ts} ) / 60; } } @@ -88,8 +88,9 @@ sub list_candidates { my $range_start = $now->clone->subtract( months => 6 ); my @journeys = $self->get_user_travels( - after => $range_start, - before => $now + after => $range_start, + before => $now, + with_datetime => 1, ); @journeys = grep { $_->{sched_arrival}->epoch and $_->{rt_arrival}->epoch } @journeys; @@ -112,9 +113,10 @@ sub list_candidates { @journeys = grep { $_->{delay} >= 60 or $_->{connection_missed} } @journeys; my @cancelled = $self->get_user_travels( - after => $range_start, - before => $now, - cancelled => 1 + after => $range_start, + before => $now, + cancelled => 1, + with_datetime => 1, ); for my $journey (@cancelled) { @@ -126,8 +128,8 @@ sub list_candidates { $self->mark_substitute_connection($journey); if ( not $journey->{has_substitute} - or $journey->{to_substitute}->{rt_arrival}->epoch - - $journey->{sched_arrival}->epoch >= 3600 ) + or $journey->{to_substitute}->{rt_arr_ts} - $journey->{sched_arr_ts} + >= 3600 ) { push( @journeys, $journey ); } @@ -162,9 +164,10 @@ sub generate { } my $journey = $self->get_journey( - uid => $uid, - journey_id => $journey_id, - verbose => 1, + uid => $uid, + journey_id => $journey_id, + verbose => 1, + with_datetime => 1, ); if ( not $journey ) { @@ -185,9 +188,10 @@ sub generate { } elsif ( $journey->{delay} < 120 ) { my @connections = $self->get_user_travels( - uid => $uid, - after => $journey->{rt_arrival}, - before => $journey->{rt_arrival}->clone->add( hours => 2 ) + uid => $uid, + after => $journey->{rt_arrival}, + before => $journey->{rt_arrival}->clone->add( hours => 2 ), + with_datetime => 1, ); if (@connections) { $self->mark_if_missed_connection( $journey, $connections[-1] ); diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index c05586a..56de0fb 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -397,7 +397,10 @@ sub redirect_to_station { sub cancelled { my ($self) = @_; - my @journeys = $self->get_user_travels( cancelled => 1 ); + my @journeys = $self->get_user_travels( + cancelled => 1, + with_datetime => 1 + ); $self->respond_to( json => { json => [@journeys] }, @@ -419,7 +422,6 @@ sub map_history { my $location = $self->app->coordinates_by_station; -# TODO create map-specific get_user_travels function returning EVA/DS100 station codes? my @journeys = $self->get_user_travels; if ( not @journeys ) { @@ -428,8 +430,6 @@ sub map_history { with_map => 1, station_coordinates => [], station_pairs => [], - range_from => 0, - range_to => 0, ); return; } @@ -494,8 +494,6 @@ sub map_history { with_map => 1, station_coordinates => \@station_coordinates, station_pairs => \@station_pairs, - range_from => $first_departure, - range_to => $last_departure, ); } @@ -515,7 +513,7 @@ sub yearly_history { # -> Limit time range to avoid accidental DoS. if ( not( $year =~ m{ ^ [0-9]{4} $ }x and $year > 1990 and $year < 2100 ) ) { - @journeys = $self->get_user_travels; + @journeys = $self->get_user_travels( with_datetime => 1 ); } else { my $interval_start = DateTime->new( @@ -529,8 +527,9 @@ sub yearly_history { ); my $interval_end = $interval_start->clone->add( years => 1 ); @journeys = $self->get_user_travels( - after => $interval_start, - before => $interval_end + after => $interval_start, + before => $interval_end, + with_datetime => 1 ); $stats = $self->get_journey_stats( year => $year ); } @@ -572,7 +571,7 @@ sub monthly_history { and $month < 13 ) ) { - @journeys = $self->get_user_travels; + @journeys = $self->get_user_travels( with_datetime => 1 ); } else { my $interval_start = DateTime->new( @@ -586,8 +585,9 @@ sub monthly_history { ); my $interval_end = $interval_start->clone->add( months => 1 ); @journeys = $self->get_user_travels( - after => $interval_start, - before => $interval_end + after => $interval_start, + before => $interval_end, + with_datetime => 1 ); $stats = $self->get_journey_stats( year => $year, @@ -632,9 +632,10 @@ sub journey_details { } my $journey = $self->get_journey( - uid => $uid, - journey_id => $journey_id, - verbose => 1, + uid => $uid, + journey_id => $journey_id, + verbose => 1, + with_datetime => 1, ); if ($journey) { @@ -669,8 +670,9 @@ sub edit_journey { } my $journey = $self->get_journey( - uid => $uid, - journey_id => $journey_id + uid => $uid, + journey_id => $journey_id, + with_datetime => 1, ); if ( not $journey ) { @@ -732,10 +734,11 @@ sub edit_journey { if ( not $error ) { $journey = $self->get_journey( - uid => $uid, - db => $db, - journey_id => $journey_id, - verbose => 1 + uid => $uid, + db => $db, + journey_id => $journey_id, + verbose => 1, + with_datetime => 1, ); $error = $self->journey_sanity_check($journey); } |