blob: 8910d683186289a63d1247f99b9a7a76e500219e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# frozen_string_literal: true
class Scheduler::DatabaseCleanupScheduler
include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0
def perform
Conversation.left_outer_joins(:statuses).where(statuses: { id: nil }).destroy_all
AccountConversation.left_outer_joins(:statuses).where(statuses: { id: nil }).destroy_all
Tag.left_outer_joins(:statuses).where(statuses: { id: nil }).destroy_all
StatusStat.left_outer_joins(:statuses).where(statuses: { id: nil }).destroy_all
Setting.rewhere(thing_type: 'User').where.not(thing_id: User.select(:id)).destroy_all
end
end
|