Skip to content

Commit ef5bbfe

Browse files
committed
[SPPM-330] Revert "[SPPM-330] Performance: copy service performs bulk update"
This reverts commit c6433df.
1 parent 5bffb4c commit ef5bbfe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/services/projects/copy_service.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ def copy_activated_custom_fields(call)
125125
# This has to run after copy_activated_custom_fields, since that is what
126126
# actually creates most of the mappings being adjusted here.
127127
def copy_creation_wizard_flags(project)
128-
enabled_cf_ids = source.project_custom_field_project_mappings.where(creation_wizard: true).pluck(:custom_field_id)
128+
source_flags = source.project_custom_field_project_mappings.pluck(:custom_field_id, :creation_wizard).to_h
129129

130-
project.project_custom_field_project_mappings.update_all(creation_wizard: false)
131-
project.project_custom_field_project_mappings.where(custom_field_id: enabled_cf_ids).update_all(creation_wizard: true)
130+
project.project_custom_field_project_mappings.find_each do |mapping|
131+
creation_wizard = source_flags[mapping.custom_field_id]
132+
mapping.update_column(:creation_wizard, creation_wizard) unless creation_wizard.nil?
133+
end
132134
end
133135

134136
def retain_attributes(source, target)

0 commit comments

Comments
 (0)