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:
parent
6d3528c539
commit
41dc950a06
2 changed files with 3 additions and 2 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
class AccountDeletion < ActiveRecord::Base
|
class AccountDeletion < ActiveRecord::Base
|
||||||
include Diaspora::Federated::Base
|
include Diaspora::Federated::Base
|
||||||
|
|
||||||
|
scope :uncompleted, -> { where('completed_at is null') }
|
||||||
|
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
after_commit :queue_delete_account, :on => :create
|
after_commit :queue_delete_account, :on => :create
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
namespace :accounts do
|
namespace :accounts do
|
||||||
desc "Run deletions"
|
desc "Run deletions"
|
||||||
task :run_deletions => :environment do
|
task :run_deletions => :environment do
|
||||||
if ::AccountDeletion.count > 0
|
if ::AccountDeletion.uncompleted.count > 0
|
||||||
puts "Running account deletions.."
|
puts "Running account deletions.."
|
||||||
::AccountDeletion.find_each do |account_delete|
|
::AccountDeletion.uncompleted.find_each do |account_delete|
|
||||||
account_delete.perform!
|
account_delete.perform!
|
||||||
end
|
end
|
||||||
puts "OK."
|
puts "OK."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue