refactor: add dol_move_batch job which are enqueued by the cron

This commit is contained in:
simon lehericey 2024-04-10 22:18:38 +02:00
parent 676112dd6f
commit 34fae2831f
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 16 additions and 1 deletions

View file

@ -4,6 +4,8 @@ class Cron::DossierOperationLogMoveToColdStorageJob < Cron::CronJob
def perform
DossierOperationLog
.with_data
.find_each(&:move_to_cold_storage!)
.in_batches do |batch|
DossierOperationLogMoveToColdStorageBatchJob.perform_later(batch.ids)
end
end
end

View file

@ -0,0 +1,9 @@
class DossierOperationLogMoveToColdStorageBatchJob < ApplicationJob
queue_as :low_priority
def perform(ids)
DossierOperationLog.where(id: ids)
.with_data
.find_each(&:move_to_cold_storage!)
end
end

View file

@ -59,5 +59,9 @@ if Rails.env.production? && SIDEKIQ_ENABLED
class APIEntreprise::Job < ApplicationJob
self.queue_adapter = :sidekiq
end
class DossierOperationLogMoveToColdStorageBatchJob < ApplicationJob
self.queue_adapter = :sidekiq
end
end
end