summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command/maintenance.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-30 12:47:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-30 12:48:23 +0200
commit99aa3a4a0d467fd83ba78096cf34113df797f0d8 (patch)
tree3a6e4dc9b7a7bcdb73fd3071dcca3e68c218702b /lib/Travelynx/Command/maintenance.pm
parent867a5d4afbb3a5c0ad0e5dfbc10d2516e3e9123f (diff)
Implement deletion of inactive accounts
Diffstat (limited to 'lib/Travelynx/Command/maintenance.pm')
-rw-r--r--lib/Travelynx/Command/maintenance.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm
index 2030705..8c07728 100644
--- a/lib/Travelynx/Command/maintenance.pm
+++ b/lib/Travelynx/Command/maintenance.pm
@@ -13,6 +13,7 @@ sub run {
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
my $verification_deadline = $now->clone->subtract( hours => 48 );
my $deletion_deadline = $now->clone->subtract( hours => 72 );
+ my $old_deadline = $now->clone->subtract( years => 1 );
my $db = $self->app->pg->db;
my $tx = $db->begin;
@@ -80,6 +81,12 @@ sub run {
{ deletion_requested => { '<', $deletion_deadline } } );
my @uids_to_delete = $to_delete->arrays->map( sub { shift->[0] } )->each;
+ $to_delete
+ = $db->select( 'users', ['id'], { last_seen => { '<', $old_deadline } } );
+
+ push( @uids_to_delete,
+ $to_delete->arrays->map( sub { shift->[0] } )->each );
+
if ( @uids_to_delete > 10 ) {
printf STDERR (
"About to delete %d accounts, which is quite a lot.\n",