From ff662784891d608e3d1d88c0db3e3f7118cb8d4a Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Tue, 24 Jan 2017 11:50:32 -0500 Subject: [PATCH] remove LiveMetric hardcoded column includes reports put virtual columns in includes this is used by Hawkluar LiveMetrics to send the column list to the server. Changed LiveMetric virtual column detection to auto include these columns without hardcoding the class name --- app/models/live_metric.rb | 7 +++++++ app/models/miq_report/generator.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/live_metric.rb b/app/models/live_metric.rb index 3decbdd2d81..fadf0815de1 100644 --- a/app/models/live_metric.rb +++ b/app/models/live_metric.rb @@ -3,6 +3,13 @@ class LiveMetric < ActsAsArModel class LiveMetricError < RuntimeError; end + # all attributes are virtual + # - attributes are dynamically generated and would be too much work to query/declare them all + # - returning true gets the column names into the REST query (via :includes) + def self.virtual_attribute?(_c) + true + end + def self.find(*args) raw_query = args[1] validate_raw_query(raw_query) diff --git a/app/models/miq_report/generator.rb b/app/models/miq_report/generator.rb index 9f151090851..cb292139961 100644 --- a/app/models/miq_report/generator.rb +++ b/app/models/miq_report/generator.rb @@ -84,7 +84,7 @@ def get_include_for_find(includes, klass = nil) if klass.nil? klass = db_class result = {} - cols.each { |c| result.merge!(c.to_sym => {}) if klass.virtual_attribute?(c) || klass == LiveMetric } if cols + cols.each { |c| result.merge!(c.to_sym => {}) if klass.virtual_attribute?(c) } if cols end if includes.kind_of?(Hash)