mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 10:09:53 +01:00
Add scheduled job to clean up orphaned inbox entries
This commit is contained in:
parent
66142f9cad
commit
a9e4265a1a
2 changed files with 22 additions and 0 deletions
15
app/workers/scheduler/inbox_cleanup_scheduler.rb
Normal file
15
app/workers/scheduler/inbox_cleanup_scheduler.rb
Normal file
|
@ -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 a new issue