Use `dependent: :destroy_async` instead of `DeletionWorker`
This commit is contained in:
parent
0db369a9ae
commit
e7112f0244
|
@ -8,8 +8,8 @@ class User::RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
DeletionWorker.perform_async(resource.id)
|
|
||||||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||||
|
resource.destroy
|
||||||
set_flash_message :notice, :destroyed if is_flashing_format?
|
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||||
yield resource if block_given?
|
yield resource if block_given?
|
||||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||||
|
|
|
@ -27,28 +27,28 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
# attr_accessor :login
|
# attr_accessor :login
|
||||||
|
|
||||||
has_many :questions, dependent: :destroy
|
has_many :questions, dependent: :destroy_async
|
||||||
has_many :answers, dependent: :destroy
|
has_many :answers, dependent: :destroy_async
|
||||||
has_many :comments, dependent: :destroy
|
has_many :comments, dependent: :destroy_async
|
||||||
has_many :inboxes, dependent: :destroy
|
has_many :inboxes, dependent: :destroy_async
|
||||||
has_many :smiles, class_name: "Appendable::Reaction", dependent: :destroy
|
has_many :smiles, class_name: "Appendable::Reaction", dependent: :destroy_async
|
||||||
has_many :services, dependent: :destroy
|
has_many :services, dependent: :destroy_async
|
||||||
has_many :notifications, foreign_key: :recipient_id, dependent: :destroy
|
has_many :notifications, foreign_key: :recipient_id, dependent: :destroy_async
|
||||||
has_many :reports, dependent: :destroy
|
has_many :reports, dependent: :destroy_async
|
||||||
has_many :moderation_comments, dependent: :destroy
|
has_many :moderation_comments, dependent: :destroy_async
|
||||||
has_many :moderation_votes, dependent: :destroy
|
has_many :moderation_votes, dependent: :destroy_async
|
||||||
has_many :lists, dependent: :destroy
|
has_many :lists, dependent: :destroy_async
|
||||||
has_many :list_memberships, class_name: "ListMember", foreign_key: 'user_id', dependent: :destroy
|
has_many :list_memberships, class_name: "ListMember", foreign_key: 'user_id', dependent: :destroy_async
|
||||||
has_many :mute_rules, dependent: :destroy
|
has_many :mute_rules, dependent: :destroy_async
|
||||||
has_many :anonymous_blocks, dependent: :destroy
|
has_many :anonymous_blocks, dependent: :destroy_async
|
||||||
|
|
||||||
has_many :subscriptions, dependent: :destroy
|
has_many :subscriptions, dependent: :destroy_async
|
||||||
has_many :totp_recovery_codes, dependent: :destroy
|
has_many :totp_recovery_codes, dependent: :destroy_async
|
||||||
|
|
||||||
has_one :profile, dependent: :destroy
|
has_one :profile, dependent: :destroy_async
|
||||||
has_one :theme, dependent: :destroy
|
has_one :theme, dependent: :destroy_async
|
||||||
|
|
||||||
has_many :bans, class_name: 'UserBan', dependent: :destroy
|
has_many :bans, class_name: 'UserBan', dependent: :destroy_async
|
||||||
has_many :banned_users, class_name: 'UserBan',
|
has_many :banned_users, class_name: 'UserBan',
|
||||||
foreign_key: 'banned_by_id',
|
foreign_key: 'banned_by_id',
|
||||||
dependent: :nullify
|
dependent: :nullify
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
class DeletionWorker
|
|
||||||
include Sidekiq::Worker
|
|
||||||
|
|
||||||
sidekiq_options queue: :deletion, retry: false
|
|
||||||
|
|
||||||
# @param resource_id [Integer] user id passed from Devise
|
|
||||||
def perform(resource_id)
|
|
||||||
begin
|
|
||||||
User.find(resource_id).destroy!
|
|
||||||
rescue => e
|
|
||||||
logger.info "failed to delete user: #{e.message}"
|
|
||||||
Sentry.capture_exception(e)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,10 +6,10 @@ staging:
|
||||||
production:
|
production:
|
||||||
:concurrency: 25
|
:concurrency: 25
|
||||||
:queues:
|
:queues:
|
||||||
|
- default
|
||||||
- share
|
- share
|
||||||
- carrierwave
|
- carrierwave
|
||||||
- mailers
|
- mailers
|
||||||
- deletion
|
|
||||||
- question
|
- question
|
||||||
- export
|
- export
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue