-
Notifications
You must be signed in to change notification settings - Fork 897
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
Advanced_settings assoc for google refresh #17890
Conversation
InventoryCollection defininition for Google graph refresh needs this association
app/models/vm_or_template.rb
Outdated
@@ -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 |
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.
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.
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.
you're right, I thought it's needed by ems's association, but it's not
app/models/ext_management_system.rb
Outdated
@@ -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 |
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.
lets call it :vms_and_templates_advanced_settings ?
has_many :vms_and_templates_advanced_settings, :through => :vms_and_templates, :as => :advanced_settings
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 |
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.
👍 LGTM
EMS needs
advanced_settings
association for creatingInventoryCollection
namedadvanced_settings
.Used in Google (GCE cloud_manager's) graph refresh