From 58cbec8d9ef464d1b0adf11afe47339dd11b244c Mon Sep 17 00:00:00 2001 From: Gregg Tanzillo Date: Wed, 8 Mar 2017 08:56:49 -0500 Subject: [PATCH] Merge pull request #14224 from kbrock/widget_1 Speed up widget generation (cherry picked from commit 15f7ba471e1a31a482a76168b6a07a19b2cf9917) https://bugzilla.redhat.com/show_bug.cgi?id=1434150 --- app/models/metric/helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/metric/helper.rb b/app/models/metric/helper.rb index 236be14e3fc..e4f138540a3 100644 --- a/app/models/metric/helper.rb +++ b/app/models/metric/helper.rb @@ -120,7 +120,11 @@ def self.sanitize_start_end_time(interval, interval_name, start_time, end_time) end def self.remove_duplicate_timestamps(recs) - return recs if recs.empty? || !recs.all? { |r| r.kind_of?(Metric) || r.kind_of?(MetricRollup) } + if recs.respond_to?(:klass) # active record relation + return recs unless recs.klass.kind_of?(Metric) || recs.klass.kind_of?(MetricRollup) + elsif recs.empty? || !recs.all? { |r| r.kind_of?(Metric) || r.kind_of?(MetricRollup) } + return recs + end recs = recs.sort_by { |r| r.resource_type + r.resource_id.to_s + r.timestamp.iso8601 }