diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-31 19:32:41 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-31 19:32:41 +0200 |
commit | 3ce1cfc55f03ccb67b3bab13112d4594974552a4 (patch) | |
tree | 256d536d98b49b586f357575d7d580ae2cddb7f4 | |
parent | 76f6922e825ea4f4f2ca0054bdd29ccd8e9edeca (diff) |
Select journeys by ID
-rwxr-xr-x | lib/Travelynx.pm | 14 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 9 | ||||
-rw-r--r-- | templates/history.html.ep | 2 | ||||
-rw-r--r-- | templates/landingpage.html.ep | 2 |
4 files changed, 12 insertions, 15 deletions
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 @@ <tbody> % 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]; <tr> <td><%= $travel->{sched_departure}->strftime('%d.%m.%Y') %></td> <td> diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index dc559f9..2cd8f68 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -105,7 +105,7 @@ % for my $travel (get_user_travels(limit => 1)) { % if ($travel->{completed}) { <tr> - % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{checkin}->epoch . '-' . $travel->{checkout}->epoch; + % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{ids}->[1]; <td><%= $travel->{sched_departure}->strftime('%d.%m.%Y') %></td> <td><a href="<%= $detail_link %>"><%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %></a></td> <td><a href="<%= $detail_link %>"><%= $travel->{from_name} %> → <%= $travel->{to_name} %></a></td> |