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

This commit is contained in:
khall 2014-08-24 19:02:11 -07:00
parent 6d3528c539
commit 41dc950a06
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -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."