Merge pull request #10297 from demarches-simplifiees/fix_dossier_operation_log_move_to_cold_storage
Tech: améliore la performance du job du stockage a froid des traces fonctionnelles
This commit is contained in:
commit
e7f31e4d49
5 changed files with 25 additions and 2 deletions
|
@ -4,6 +4,8 @@ class Cron::DossierOperationLogMoveToColdStorageJob < Cron::CronJob
|
||||||
def perform
|
def perform
|
||||||
DossierOperationLog
|
DossierOperationLog
|
||||||
.with_data
|
.with_data
|
||||||
.find_each(&:move_to_cold_storage!)
|
.in_batches do |batch|
|
||||||
|
DossierOperationLogMoveToColdStorageBatchJob.perform_later(batch.ids)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
@ -59,5 +59,9 @@ if Rails.env.production? && SIDEKIQ_ENABLED
|
||||||
class APIEntreprise::Job < ApplicationJob
|
class APIEntreprise::Job < ApplicationJob
|
||||||
self.queue_adapter = :sidekiq
|
self.queue_adapter = :sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class DossierOperationLogMoveToColdStorageBatchJob < ApplicationJob
|
||||||
|
self.queue_adapter = :sidekiq
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
db/migrate/20240410193614_add_partial_index_on_dol.rb
Normal file
7
db/migrate/20240410193614_add_partial_index_on_dol.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AddPartialIndexOnDol < ActiveRecord::Migration[7.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :dossier_operation_logs, :id, where: 'data is not null', algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2024_04_02_212902) do
|
ActiveRecord::Schema[7.0].define(version: 2024_04_10_193614) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_buffercache"
|
enable_extension "pg_buffercache"
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
|
@ -420,6 +420,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_02_212902) do
|
||||||
t.datetime "updated_at", precision: nil, null: false
|
t.datetime "updated_at", precision: nil, null: false
|
||||||
t.index ["bill_signature_id"], name: "index_dossier_operation_logs_on_bill_signature_id"
|
t.index ["bill_signature_id"], name: "index_dossier_operation_logs_on_bill_signature_id"
|
||||||
t.index ["dossier_id"], name: "index_dossier_operation_logs_on_dossier_id"
|
t.index ["dossier_id"], name: "index_dossier_operation_logs_on_dossier_id"
|
||||||
|
t.index ["id"], name: "index_dossier_operation_logs_on_id", where: "(data IS NOT NULL)"
|
||||||
t.index ["keep_until"], name: "index_dossier_operation_logs_on_keep_until"
|
t.index ["keep_until"], name: "index_dossier_operation_logs_on_keep_until"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue