pj migration: reduce the number of queries by preloading champs
This commit is contained in:
parent
60121a1be6
commit
a168ae3a72
1 changed files with 1 additions and 1 deletions
|
@ -37,7 +37,7 @@ class PieceJustificativeToChampPieceJointeMigrationService
|
|||
procedure.types_de_champ += types_de_champ_pj
|
||||
|
||||
# Unscope to make sure all dossiers are migrated, even the soft-deleted ones
|
||||
procedure.dossiers.unscope(where: :hidden_at).find_each do |dossier|
|
||||
procedure.dossiers.unscope(where: :hidden_at).includes(:champs).find_each do |dossier|
|
||||
champs_pj = types_de_champ_pj.map(&:build_champ)
|
||||
dossier.champs += champs_pj
|
||||
|
||||
|
|
Loading…
Reference in a new issue