Add scheduled job to clean up orphaned inbox entries
This commit is contained in:
parent
66142f9cad
commit
a9e4265a1a
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::InboxCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: false
|
||||
|
||||
def perform
|
||||
orphaned_entries = Inbox.where(question_id: nil).includes(:user)
|
||||
orphaned_entries.each do |inbox|
|
||||
logger.info "Deleting orphaned inbox entry #{inbox.id} from user #{inbox.user.id}"
|
||||
inbox.destroy
|
||||
end
|
||||
end
|
||||
end
|
|
@ -13,4 +13,11 @@ production:
|
|||
- question
|
||||
- export
|
||||
- push_notification
|
||||
- scheduler
|
||||
|
||||
:scheduler:
|
||||
:schedule:
|
||||
inbox_cleanup:
|
||||
every: 1m
|
||||
class: Scheduler::InboxCleanupScheduler
|
||||
queue: scheduler
|
||||
|
|
Loading…
Reference in New Issue