summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-10-18 08:50:25 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-10-18 08:50:25 +0200
commitd7fc6ceb3a95f2dadd899c4e9b221a8a11327fc1 (patch)
treef4c0de1bcd84d5767861bbd0ce33aa046f45b5d7 /index.pl
parentb070e55eaeb6df7cb39235463ca7df7dd2c6bcc0 (diff)
handle consecutive checkins by ignoring previous ones
Diffstat (limited to 'index.pl')
-rwxr-xr-xindex.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/index.pl b/index.pl
index bb3fee8..c86fe5b 100755
--- a/index.pl
+++ b/index.pl
@@ -453,6 +453,7 @@ helper 'get_user_travels' => sub {
$query->execute($uid);
my @travels;
+ my $prev_action = 0;
while ( my @row = $query->fetchrow_array ) {
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];
$ref->{from_name} = $name;
$ref->{completed} = 1;
@@ -496,6 +497,7 @@ helper 'get_user_travels' => sub {
$ref->{messages} //= [ split( qr{[|]}, $raw_messages ) ];
$ref->{route} //= [ split( qr{[|]}, $raw_route ) ];
}
+ $prev_action = $action;
}
return @travels;