Select journeys by ID
This commit is contained in:
parent
76f6922e82
commit
3ce1cfc55f
4 changed files with 12 additions and 15 deletions
|
@ -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} )
|
||||
{
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue