Skip to content

Commit

Permalink
Merge pull request #12636 from zeari/fix_caching_report_fields
Browse files Browse the repository at this point in the history
Dont cache dynamic report fields
(cherry picked from commit 1a3ecd7)

https://bugzilla.redhat.com/show_bug.cgi?id=1417197
  • Loading branch information
gtanzillo authored and simaishi committed Jan 27, 2017
1 parent 8a5f4d5 commit f457f4a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,10 @@ def self.model_details(model, opts = {:typ => "all", :include_model => true, :in

result = []
unless opts[:typ] == "count" || opts[:typ] == "find"
result = get_column_details(relats[:columns], model, model, opts).sort! { |a, b| a.to_s <=> b.to_s }
@column_cache ||= {}
key = "#{model}_#{opts[:interval]}_#{opts[:include_model] || false}"
@column_cache[key] ||= get_column_details(relats[:columns], model, model, opts).sort! { |a, b| a.to_s <=> b.to_s }
result.concat(@column_cache[key])

unless opts[:disallow_loading_virtual_custom_attributes]
custom_details = _custom_details_for(model, opts)
Expand Down Expand Up @@ -1223,18 +1226,15 @@ def self.miq_adv_search_lists(model, what)
def self.reporting_available_fields(model, interval = nil)
@reporting_available_fields ||= {}
if model.to_s == "VimPerformanceTrend"
@reporting_available_fields[model.to_s] ||= {}
@reporting_available_fields[model.to_s][interval.to_s] ||= VimPerformanceTrend.trend_model_details(interval.to_s)
VimPerformanceTrend.trend_model_details(interval.to_s)
elsif model.ends_with?("Performance")
@reporting_available_fields[model.to_s] ||= {}
@reporting_available_fields[model.to_s][interval.to_s] ||= MiqExpression.model_details(model, :include_model => false, :include_tags => true, :interval => interval)
MiqExpression.model_details(model, :include_model => false, :include_tags => true, :interval => interval)
elsif Chargeback.db_is_chargeback?(model)
cb_model = Chargeback.report_cb_model(model)
@reporting_available_fields[model.to_s] ||=
MiqExpression.model_details(model, :include_model => false, :include_tags => true).select { |c| c.last.ends_with?(*ReportController::Reports::Editor::CHARGEBACK_ALLOWED_FIELD_SUFFIXES) } +
MiqExpression.tag_details(cb_model, model, {}) + _custom_details_for(cb_model, {})
else
@reporting_available_fields[model.to_s] ||= MiqExpression.model_details(model, :include_model => false, :include_tags => true)
MiqExpression.model_details(model, :include_model => false, :include_tags => true)
end
end

Expand Down

0 comments on commit f457f4a

Please sign in to comment.