Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

agrare
Copy link
Member

@agrare agrare commented Oct 10, 2017

Save the parent_id for a Lan for SCVMM VMNetworks

parent_id = h.fetch_path(:parent, :id)
next if parent_id.nil?

switch.lans.find(h[:id]).update_attributes(:parent_id => parent_id)
Copy link
Member Author

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?

Copy link
Contributor

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?
Copy link
Contributor

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?

@agrare agrare force-pushed the lan_parent_child_relationship branch from c25bbd3 to e3d92f4 Compare October 11, 2017 12:43
@agrare
Copy link
Member Author

agrare commented Oct 11, 2017

@Ladas updated, can you take another look?

@agrare agrare force-pushed the lan_parent_child_relationship branch from e3d92f4 to b68a81c Compare October 11, 2017 16:24
@miq-bot
Copy link
Member

miq-bot commented Oct 11, 2017

Checked commit agrare@b68a81c with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 1 offense detected

app/models/ems_refresh/save_inventory_infra.rb

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now

@agrare agrare changed the title [WIP] Save the Lan parent_id for SCVMM Save the Lan parent_id for SCVMM Oct 11, 2017
@agrare agrare removed the wip label Oct 11, 2017
@blomquisg blomquisg merged commit 7e4db98 into ManageIQ:master Oct 11, 2017
@blomquisg blomquisg added this to the Sprint 71 Ending Oct 16, 2017 milestone Oct 11, 2017
@agrare agrare deleted the lan_parent_child_relationship branch October 11, 2017 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants