From 41dc950a06f9acaa09f1c889b35a74ae7f28b41d Mon Sep 17 00:00:00 2001 From: khall Date: Sun, 24 Aug 2014 19:02:11 -0700 Subject: [PATCH] Adding scope for account_deletion to get only those that are uncompleted and then adding that scope to accounts.rake. Tested it out and it works well --- app/models/account_deletion.rb | 1 + lib/tasks/accounts.rake | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/account_deletion.rb b/app/models/account_deletion.rb index 7b1886269..a8918d587 100644 --- a/app/models/account_deletion.rb +++ b/app/models/account_deletion.rb @@ -5,6 +5,7 @@ class AccountDeletion < ActiveRecord::Base include Diaspora::Federated::Base + scope :uncompleted, -> { where('completed_at is null') } belongs_to :person after_commit :queue_delete_account, :on => :create diff --git a/lib/tasks/accounts.rake b/lib/tasks/accounts.rake index 91bfd7a02..fb79a2730 100644 --- a/lib/tasks/accounts.rake +++ b/lib/tasks/accounts.rake @@ -1,9 +1,9 @@ namespace :accounts do desc "Run deletions" task :run_deletions => :environment do - if ::AccountDeletion.count > 0 + if ::AccountDeletion.uncompleted.count > 0 puts "Running account deletions.." - ::AccountDeletion.find_each do |account_delete| + ::AccountDeletion.uncompleted.find_each do |account_delete| account_delete.perform! end puts "OK."