File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
app/models/manageiq/providers/inventory/persister/builder Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -165,17 +165,23 @@ def vm_and_miq_template_ancestry_save_block
165165
166166 # Fetch IDs of all vms and genealogy_parents, only if genealogy_parent is present
167167 vms_genealogy_parents = vms_inventory_collection . data . each_with_object ( { } ) do |x , obj |
168- unless x . data [ :genealogy_parent ] . nil?
169- genealogy_parent_id = x . data [ :genealogy_parent ] . load . try ( :id )
170- obj [ x . id ] = genealogy_parent_id if genealogy_parent_id
171- end
168+ next if x . data [ :genealogy_parent ] . nil?
169+
170+ genealogy_parent_id = x . data [ :genealogy_parent ] . load . try ( :id )
171+ next if genealogy_parent_id . nil?
172+ next if genealogy_parent_id == x . id
173+
174+ obj [ x . id ] = genealogy_parent_id
172175 end
173176
174177 miq_template_genealogy_parents = miq_templates_inventory_collection . data . each_with_object ( { } ) do |x , obj |
175- unless x . data [ :genealogy_parent ] . nil?
176- genealogy_parent_id = x . data [ :genealogy_parent ] . load . try ( :id )
177- obj [ x . id ] = genealogy_parent_id if genealogy_parent_id
178- end
178+ next if x . data [ :genealogy_parent ] . nil?
179+
180+ genealogy_parent_id = x . data [ :genealogy_parent ] . load . try ( :id )
181+ next if genealogy_parent_id . nil?
182+ next if genealogy_parent_id == x . id
183+
184+ obj [ x . id ] = genealogy_parent_id
179185 end
180186
181187 ActiveRecord ::Base . transaction do
You can’t perform that action at this time.
0 commit comments