diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2019-12-20 18:56:57 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-20 18:56:57 +0100 | 
| commit | c6634b409750e7c79f7c4369a7c7ec5929868214 (patch) | |
| tree | 67cfb7b204444aace135c9105ed89a00bceea4a1 | |
| parent | e7f278574fa1c5f8896791c9444868b7f60760e3 (diff) | |
maintenance: remove checkins which were entered more than 48 hours ago1.11.8
| -rw-r--r-- | lib/Travelynx/Command/maintenance.pm | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm index fc64884..5cbf982 100644 --- a/lib/Travelynx/Command/maintenance.pm +++ b/lib/Travelynx/Command/maintenance.pm @@ -3,14 +3,15 @@ use Mojo::Base 'Mojolicious::Command';  use DateTime; -has description => 'Prune unverified users etc'; +has description => 'Prune unverified users, incomplete checkins etc';  has usage => sub { shift->extract_usage };  sub run {  	my ( $self, $filename ) = @_; -	my $now = DateTime->now( time_zone => 'Europe/Berlin' ); +	my $now                   = DateTime->now( time_zone => 'Europe/Berlin' ); +	my $checkin_deadline      = $now->clone->subtract( hours => 48 );  	my $verification_deadline = $now->clone->subtract( hours => 48 );  	my $deletion_deadline     = $now->clone->subtract( hours => 72 );  	my $old_deadline          = $now->clone->subtract( years => 1 ); @@ -18,6 +19,13 @@ sub run {  	my $db = $self->app->pg->db;  	my $tx = $db->begin; +	my $res = $db->delete( 'in_transit', +		{ checkin_time => { '<', $checkin_deadline } } ); + +	if ( my $rows = $res->rows ) { +		printf( "Removed %d incomplete checkins\n", $rows ); +	} +  	my $unverified = $db->select(  		'users',  		'id, email, extract(epoch from registered_at) as registered_ts', @@ -64,7 +72,7 @@ sub run {  		printf( "Pruned unverified user %d\n", $user->{id} );  	} -	my $res = $db->delete( 'pending_passwords', +	$res = $db->delete( 'pending_passwords',  		{ requested_at => { '<', $verification_deadline } } );  	if ( my $rows = $res->rows ) { | 
