From 7a5dc8eaed08e1a740f8fec60333f903f6fad4f6 Mon Sep 17 00:00:00 2001 From: Tim Wade Date: Fri, 20 Oct 2017 13:32:58 -0700 Subject: [PATCH 1/2] Revert "Include reflections of descendant classes when building model details for reporting and expression editors" This reverts commit a7597b65273b9c6089ee19a887cd85c72d1f8f08. Conflicts: app/models/host.rb app/models/miq_expression.rb config/locales/en.yml spec/models/miq_expression/miq_expression_spec.rb --- app/models/host.rb | 4 ---- app/models/vm.rb | 4 ---- lib/miq_expression.rb | 7 +------ spec/lib/miq_expression_spec.rb | 17 ----------------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/app/models/host.rb b/app/models/host.rb index 154722aa06c..8693f5be230 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -181,10 +181,6 @@ class Host < ApplicationRecord end end - def self.include_descendant_classes_in_expressions? - true - end - def self.non_clustered where(:ems_cluster_id => nil) end diff --git a/app/models/vm.rb b/app/models/vm.rb index e338943511f..a116dfa1a80 100644 --- a/app/models/vm.rb +++ b/app/models/vm.rb @@ -12,10 +12,6 @@ def self.base_model Vm end - def self.include_descendant_classes_in_expressions? - true - end - def self.corresponding_model if self == Vm MiqTemplate diff --git a/lib/miq_expression.rb b/lib/miq_expression.rb index 8a8ec095c10..cf79cebb1d6 100644 --- a/lib/miq_expression.rb +++ b/lib/miq_expression.rb @@ -949,12 +949,7 @@ def self.build_relats(model, parent = {}, seen = []) result = {:columns => model.attribute_names, :parent => parent} result[:reflections] = {} - refs = model.reflections_with_virtual - if model.try(:include_descendant_classes_in_expressions?) - model.descendants.each { |desc| refs.reverse_merge!(desc.reflections_with_virtual) } - end - - refs.each do |assoc, ref| + model.reflections_with_virtual.each do |assoc, ref| next unless INCLUDE_TABLES.include?(assoc.to_s.pluralize) next if assoc.to_s.pluralize == "event_logs" && parent[:root] == "Host" && !proto? next if assoc.to_s.pluralize == "processes" && parent[:root] == "Host" # Process data not available yet for Host diff --git a/spec/lib/miq_expression_spec.rb b/spec/lib/miq_expression_spec.rb index 271dc22edb7..65b76c47bf6 100644 --- a/spec/lib/miq_expression_spec.rb +++ b/spec/lib/miq_expression_spec.rb @@ -2085,23 +2085,6 @@ end end - context ".build_relats" do - it "includes reflections from descendant classes of Vm" do - relats = MiqExpression.get_relats(Vm) - expect(relats[:reflections][:cloud_tenant]).not_to be_blank - end - - it "includes reflections from descendant classes of Host" do - relats = MiqExpression.get_relats(Host) - expect(relats[:reflections][:cloud_networks]).not_to be_blank - end - - it "excludes reflections from descendant classes of VmOrTemplate " do - relats = MiqExpression.get_relats(VmOrTemplate) - expect(relats[:reflections][:cloud_tenant]).to be_blank - end - end - describe "#to_human" do it "generates a human readable string for a 'FIELD' expression" do exp = MiqExpression.new(">" => {"field" => "Vm-allocated_disk_storage", "value" => "5.megabytes"}) From 9837f2f9ae13c88c74619ba27ac88e9ee1a03ec4 Mon Sep 17 00:00:00 2001 From: Tim Wade Date: Fri, 20 Oct 2017 13:47:45 -0700 Subject: [PATCH 2/2] Add tenants to include tables Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1236001 --- config/miq_expression.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/miq_expression.yml b/config/miq_expression.yml index d07b14cff1b..ebb86b4523c 100644 --- a/config/miq_expression.yml +++ b/config/miq_expression.yml @@ -155,6 +155,7 @@ - storage_files - switches - tenant_quotas +- tenants - users - vms - volumes