Skip to content

Commit

Permalink
Merge pull request #13640 from kbrock/report_live_metric
Browse files Browse the repository at this point in the history
remove LiveMetric hardcoded column includes
  • Loading branch information
gtanzillo authored Feb 7, 2017
2 parents 1ab7103 + ff66278 commit 65d2b91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/models/live_metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def include_as_hash(includes = include, 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)
Expand Down

0 comments on commit 65d2b91

Please sign in to comment.