summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command/work.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-07 19:06:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-03-07 19:06:21 +0100
commit574e83d56727a088d57d4bb1c7dcd37a2c67f1fd (patch)
tree1fdf0ac2a26c2575a7aac15eb8f98dff1ae9fd3e /lib/Travelynx/Command/work.pm
parenta21826a055a5f477560537f4bd022a7cdb15d50a (diff)
Move incomplete checkin removal from "maintenance" to "work" task
Diffstat (limited to 'lib/Travelynx/Command/work.pm')
-rw-r--r--lib/Travelynx/Command/work.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 961a48c..24621b5 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -17,11 +17,19 @@ has usage => sub { shift->extract_usage };
sub run {
my ($self) = @_;
- my $now = DateTime->now( time_zone => 'Europe/Berlin' );
- my $json = JSON->new;
+ my $now = DateTime->now( time_zone => 'Europe/Berlin' );
+ my $checkin_deadline = $now->clone->subtract( hours => 48 );
+ my $json = JSON->new;
my $db = $self->app->pg->db;
+ my $res = $db->delete( 'in_transit',
+ { checkin_time => { '<', $checkin_deadline } } );
+
+ if ( my $rows = $res->rows ) {
+ $self->app->log->debug("Removed ${rows} incomplete checkins");
+ }
+
for my $entry (
$db->select( 'in_transit_str', '*', { cancelled => 0 } )->hashes->each )
{