Skip to content

Commit

Permalink
Merge pull request #14224 from kbrock/widget_1
Browse files Browse the repository at this point in the history
Speed up widget generation
(cherry picked from commit 15f7ba4)

https://bugzilla.redhat.com/show_bug.cgi?id=1434150
  • Loading branch information
gtanzillo authored and simaishi committed Mar 20, 2017
1 parent 4fd19f5 commit 58cbec8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/metric/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 58cbec8

Please sign in to comment.