Skip to content

Commit

Permalink
remove LiveMetric hardcoded column includes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kbrock committed Jan 26, 2017
1 parent 3bb179f commit ff66278
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 @@ -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)
Expand Down

0 comments on commit ff66278

Please sign in to comment.