Skip to content

Commit

Permalink
Fill resource id only to new targets
Browse files Browse the repository at this point in the history
Fill resource id only to new targets, to avoid growing query.
  • Loading branch information
Ladas authored and agrare committed Nov 22, 2017
1 parent f0f2e91 commit e8a467c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/ems_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def self.queue_merge(targets, ems, create_task = false)
# If this is the only refresh then we will use the task we just created,
# if we merge with another queue item then we will return its task_id
task_id = nil
new_targets = targets

# Items will be naturally serialized since there is a dedicated worker.
miq_queue_record = MiqQueue.put_or_update(queue_options) do |msg, item|
Expand Down Expand Up @@ -195,9 +196,9 @@ def self.queue_merge(targets, ems, create_task = false)
)
end

if targets.present?
if new_targets.present?
# If we are storing data, we want to make sure any BinaryBlob present will be tied back to this MiqQueue record
payload_ids = targets.map do |type, target_hash|
payload_ids = new_targets.map do |type, target_hash|
next if type != "ManagerRefresh::Target"
target_hash[:payload_id]
end.compact
Expand Down

0 comments on commit e8a467c

Please sign in to comment.