handle consecutive checkins by ignoring previous ones
This commit is contained in:
parent
b070e55eae
commit
d7fc6ceb3a
1 changed files with 3 additions and 1 deletions
4
index.pl
4
index.pl
|
@ -453,6 +453,7 @@ helper 'get_user_travels' => sub {
|
||||||
$query->execute($uid);
|
$query->execute($uid);
|
||||||
|
|
||||||
my @travels;
|
my @travels;
|
||||||
|
my $prev_action = 0;
|
||||||
|
|
||||||
while ( my @row = $query->fetchrow_array ) {
|
while ( my @row = $query->fetchrow_array ) {
|
||||||
my (
|
my (
|
||||||
|
@ -484,7 +485,7 @@ helper 'get_user_travels' => sub {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ( $action == $action_type{checkin} and @travels ) {
|
elsif ( $action == $action_type{checkin} and $prev_action == $action_type{checkout} ) {
|
||||||
my $ref = $travels[-1];
|
my $ref = $travels[-1];
|
||||||
$ref->{from_name} = $name;
|
$ref->{from_name} = $name;
|
||||||
$ref->{completed} = 1;
|
$ref->{completed} = 1;
|
||||||
|
@ -496,6 +497,7 @@ helper 'get_user_travels' => sub {
|
||||||
$ref->{messages} //= [ split( qr{[|]}, $raw_messages ) ];
|
$ref->{messages} //= [ split( qr{[|]}, $raw_messages ) ];
|
||||||
$ref->{route} //= [ split( qr{[|]}, $raw_route ) ];
|
$ref->{route} //= [ split( qr{[|]}, $raw_route ) ];
|
||||||
}
|
}
|
||||||
|
$prev_action = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
return @travels;
|
return @travels;
|
||||||
|
|
Loading…
Reference in a new issue