Class: Nuntius::PurgeMessageJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Nuntius::PurgeMessageJob
- Defined in:
- app/jobs/nuntius/purge_message_job.rb
Instance Method Summary collapse
Instance Method Details
#perform(account_id, months) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/jobs/nuntius/purge_message_job.rb', line 3 def perform(account_id, months) = Nuntius::Message.distinct.select(:id).where("metadata ->> 'account_id' = :account", account: account_id) .where(created_at: ..months.months.ago.beginning_of_day) .where.not(status: %w[complaint bounced]) Nuntius::Message.where(parent_message_id: .pluck(:id)).in_batches.update_all(parent_message_id: nil) .in_batches.destroy_all end |