Skip to content

Commit

Permalink
Associate subnets with routers with less queries
Browse files Browse the repository at this point in the history
Associate subnets with routers with less queries, 50% of the
DB queries exactly.
  • Loading branch information
Ladas committed Apr 11, 2017
1 parent d0dc3e3 commit 8307f2a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions app/models/ems_refresh/save_inventory_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,8 @@ def save_load_balancer_health_check_members_inventory(load_balancer_health_check
def link_cloud_subnets_to_network_routers(hashes)
return if hashes.blank?

cloud_subnets = CloudSubnet.where(:id => hashes.map { |x| x[:id] }.compact.uniq).find_each.index_by(&:id)

hashes.each do |hash|
network_router = hash.fetch_path(:network_router, :id)
cloud_subnet = cloud_subnets[hash[:id]]
cloud_subnet.update_attributes(:network_router_id => network_router) if cloud_subnet
CloudSubnet.where(:id => hash[:id]).update_all(:network_router_id => hash.fetch_path(:network_router, :id))
end
end
end

0 comments on commit 8307f2a

Please sign in to comment.