-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save the Lan parent_id for SCVMM #16165
Save the Lan parent_id for SCVMM #16165
Conversation
parent_id = h.fetch_path(:parent, :id) | ||
next if parent_id.nil? | ||
|
||
switch.lans.find(h[:id]).update_attributes(:parent_id => parent_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ladas I'm sure you can think of a better way to do this, but I saved everything first then update the parent_id so there aren't any issues with order dependency and made the disconnects simpler. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lan.where(:id => h[:id]).update_all(:parent_id => parent_id)
the query before was doing extra join and extra select, then update. This will do the same in 1 update query.
next if h[:id].nil? | ||
|
||
parent_id = h.fetch_path(:parent, :id) | ||
next if parent_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a one liner?
next if (parent_id = h.fetch_path(:parent, :id)).nil?
c25bbd3
to
e3d92f4
Compare
@Ladas updated, can you take another look? |
e3d92f4
to
b68a81c
Compare
Checked commit agrare@b68a81c with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 app/models/ems_refresh/save_inventory_infra.rb
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now
Save the parent_id for a Lan for SCVMM VMNetworks