first test for sidekiq

This commit is contained in:
simon lehericey 2023-11-13 10:52:45 +01:00
parent c6ae4139a2
commit e00054a6ea
2 changed files with 20 additions and 6 deletions

View file

@ -0,0 +1,9 @@
sidekiq_enabled = ENV.has_key?('REDIS_SIDEKIQ_SENTINELS') || ENV.has_key?('REDIS_URL')
if Rails.env.production? && sidekiq_enabled
ActiveSupport.on_load(:after_initialize) do
class ActiveStorage::PurgeJob < ActiveStorage::BaseJob
self.queue_adapter = :sidekiq
end
end
end

View file

@ -1,14 +1,17 @@
namespace :after_party do namespace :after_party do
desc 'Deployment task: remove_orphan_dossier_operation_logs' desc 'Deployment task: remove_orphan_dossier_operation_logs. You can add JOB_LIMIT env var to limit the load and manually relaunch the process if needed.'
task remove_orphan_dossier_operation_logs: :environment do task remove_orphan_dossier_operation_logs: :environment do
puts "Running deploy task 'remove_orphan_dossier_operation_logs'" puts "Running deploy task 'remove_orphan_dossier_operation_logs'"
job_limit = 200_000 job_limit = ENV['JOB_LIMIT']
not_deletion_orphans = DossierOperationLog not_deletion_orphans = DossierOperationLog
.not_deletion .not_deletion
.where.missing(:dossier) .where.missing(:dossier)
.limit(job_limit)
if job_limit.present?
not_deletion_orphans = not_deletion_orphans.limit(job_limit)
end
batch_size = 1_000 batch_size = 1_000
@ -23,9 +26,11 @@ namespace :after_party do
rake_puts "Supression des serialized des dols avec operation == supprimer" rake_puts "Supression des serialized des dols avec operation == supprimer"
deletion_orphans = DossierOperationLog deletion_orphans = DossierOperationLog.supprimer
.supprimer
.limit(job_limit) if job_limit.present?
deletion_orphans = deletion_orphans.limit(job_limit)
end
progress = ProgressReport.new(deletion_orphans.count) progress = ProgressReport.new(deletion_orphans.count)