Skip to content

Commit

Permalink
Fix Containers dashboard heatmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
zakiva committed Apr 24, 2017
1 parent 27e1ab0 commit 6a8ebf3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/metric/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,12 @@ def self.get_time_interval(obj, timestamp)

start_time..timestamp
end

def self.latest_metrics(resource_type, resource_ids = nil)
metrics = Metric.where(:resource_type => resource_type)
metrics = metrics.where(:resource_id => resource_ids) if resource_ids
metrics = metrics.order(:resource_id, :timestamp => :desc)
metrics = metrics.where('timestamp > ?', 10.minutes.ago.utc)
metrics.select('DISTINCT ON (metrics.resource_id) metrics.*')
end
end

0 comments on commit 6a8ebf3

Please sign in to comment.