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

Advanced_settings assoc for google refresh #17890

Merged
merged 2 commits into from
Aug 24, 2018

Conversation

slemrmartin
Copy link
Contributor

EMS needs advanced_settings association for creating InventoryCollection named advanced_settings.

Used in Google (GCE cloud_manager's) graph refresh

InventoryCollection defininition for Google graph refresh needs this association
@miq-bot miq-bot added the wip label Aug 22, 2018
@slemrmartin slemrmartin changed the title [WIP] Advanced_settings assoc for google refresh Advanced_settings assoc for google refresh Aug 22, 2018
@slemrmartin
Copy link
Contributor Author

cc @Ladas @agrare please review

@miq-bot miq-bot removed the wip label Aug 22, 2018
@@ -102,7 +102,7 @@ class VmOrTemplate < ApplicationRecord

has_many :scan_histories, :dependent => :destroy
has_many :lifecycle_events, :class_name => "LifecycleEvent"
has_many :advanced_settings, :as => :resource, :dependent => :destroy
has_many :advanced_settings, -> { where(:resource_type => "VmOrTemplate") }, :as => :resource, :dependent => :destroy
Copy link
Member

@agrare agrare Aug 22, 2018

Choose a reason for hiding this comment

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

Is this necessary? Doesn't the query for advanced_settings already have where resource_id = id AND resource_type = VmOrTemplate?

>> vm.advanced_settings
  AdvancedSetting Load (0.3ms)  SELECT "advanced_settings".* FROM "advanced_settings" WHERE "advanced_settings"."resource_id" = $1 AND "advanced_settings"."resource_type" = $2  [["resource_id", 1], ["resource_type", "VmOrTemplate"]]

And with your change:

>> vm.advanced_settings
  AdvancedSetting Load (1.7ms)  SELECT "advanced_settings".* FROM "advanced_settings" WHERE "advanced_settings"."resource_id" = $1 AND "advanced_settings"."resource_type" = $2 AND "advanced_settings"."resource_type" = $3  [["resource_id", 1], ["resource_type", "VmOrTemplate"], ["resource_type", "VmOrTemplate"]]

looks like an extra duplicated where clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, I thought it's needed by ems's association, but it's not

@@ -77,6 +77,8 @@ def self.api_allowed_attributes
has_many :miq_events, :as => :target, :dependent => :destroy
has_many :cloud_subnets, :foreign_key => :ems_id, :dependent => :destroy

has_many :advanced_settings, :through => :vms_and_templates
Copy link
Contributor

@Ladas Ladas Aug 23, 2018

Choose a reason for hiding this comment

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

lets call it :vms_and_templates_advanced_settings ?

has_many :vms_and_templates_advanced_settings, :through => :vms_and_templates, :as => :advanced_settings

@miq-bot
Copy link
Member

miq-bot commented Aug 24, 2018

Checked commits slemrmartin/manageiq@a6decbd~...0399e89 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@agrare agrare merged commit a962f4f into ManageIQ:master Aug 24, 2018
@agrare agrare self-assigned this Aug 24, 2018
@agrare agrare added this to the Sprint 93 Ending Aug 27, 2018 milestone Aug 24, 2018
@slemrmartin slemrmartin deleted the adv-settings-google-refresh branch August 24, 2018 14:09
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