diff options
Diffstat (limited to 'app/workers/scheduler')
-rw-r--r-- | app/workers/scheduler/database_cleanup_scheduler.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/workers/scheduler/database_cleanup_scheduler.rb b/app/workers/scheduler/database_cleanup_scheduler.rb new file mode 100644 index 000000000..8910d6831 --- /dev/null +++ b/app/workers/scheduler/database_cleanup_scheduler.rb @@ -0,0 +1,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 |