Skip to content

Commit

Permalink
Merge pull request #17570 from slemrmartin/inventory-collection-builder2
Browse files Browse the repository at this point in the history
Skip Vm reconnect if already reconnected
  • Loading branch information
agrare authored Jun 12, 2018
2 parents 419aa35 + 138e112 commit bbbe63a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ module ManagerRefresh::InventoryCollection::Builder::Shared

inventory_objects_index.each_slice(100) do |batch|
batch_refs = batch.map(&:first)
relation.where(inventory_collection.manager_ref.first => batch_refs).each do |record|
relation.where(inventory_collection.manager_ref.first => batch_refs).order(:id => :asc).each do |record|
index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record)

# We need to delete the record from the inventory_objects_index
# and attributes_index, otherwise it would be sent for create.
inventory_object = inventory_objects_index.delete(index)
hash = attributes_index.delete(index)

# Skip if hash is blank, which can happen when having several archived entities with the same ref
next unless hash

record.assign_attributes(hash.except(:id, :type))
if !inventory_collection.check_changed? || record.changed?
record.save!
Expand Down

0 comments on commit bbbe63a

Please sign in to comment.