diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index b8f778a..4487898 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -339,7 +339,7 @@ sub startup { from user_actions left outer join stations on station_id = stations.id where user_id = ? - and (action_time = to_timestamp(?) or action_time = to_timestamp(?)) + and user_actions.id <= ? order by action_time desc limit 2 } @@ -898,10 +898,9 @@ qq{select * from pending_mails where email = ? and num_tries > 1;} $query = $self->app->get_last_actions_query; } - if ( $opt{checkin_epoch} and $opt{checkout_epoch} ) { + if ( $opt{checkout_id} ) { $query = $self->app->get_journey_actions_query; - $query->execute( $uid, $opt{checkin_epoch}, - $opt{checkout_epoch} ); + $query->execute( $uid, $opt{checkout_id}); } elsif ( $opt{after} and $opt{before} ) { @@ -960,7 +959,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;} if ( $action == $match_actions[0] or - ( $opt{checkout_epoch} and $raw_ts == $opt{checkout_epoch} ) + ( $opt{checkout_id} and not @travels ) ) { push( @@ -989,8 +988,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;} $action == $match_actions[1] and $prev_action == $match_actions[0] ) - or - ( $opt{checkin_epoch} and $raw_ts == $opt{checkin_epoch} ) + or $opt{checkout_id} ) { my $ref = $travels[-1]; @@ -1041,7 +1039,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;} ? $ref->{km_beeline} / $kmh_divisor : -1; } - if ( $opt{checkin_epoch} + if ( $opt{checkout_id} and $action == $self->app->action_type->{cancelled_from} ) { diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index c3ce11e..70b2246 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -310,9 +310,9 @@ sub monthly_history { sub journey_details { my ($self) = @_; - my ( $uid, $checkin_ts, $checkout_ts ) = split( qr{-}, $self->stash('id') ); + my ( $uid, $checkout_id ) = split( qr{-}, $self->stash('id') ); - if ( $uid != $self->current_user->{id} ) { + if ( not ($uid == $self->current_user->{id} and $checkout_id)) { $self->render( 'journey', error => 'notfound', @@ -323,11 +323,10 @@ sub journey_details { my @journeys = $self->get_user_travels( uid => $uid, - checkin_epoch => $checkin_ts, - checkout_epoch => $checkout_ts, + checkout_id => $checkout_id, verbose => 1, ); - if ( @journeys == 0 ) { + if ( @journeys == 0 or not $journeys[0]{completed}) { $self->render( 'journey', error => 'notfound', diff --git a/templates/history.html.ep b/templates/history.html.ep index 5fc3907..8f63296 100644 --- a/templates/history.html.ep +++ b/templates/history.html.ep @@ -79,7 +79,7 @@
% for my $travel (@{$journeys}) { % if ($travel->{completed}) { - % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{checkin}->epoch . '-' . $travel->{checkout}->epoch; + % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{ids}->[1];