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 May 22, 2017
1 parent fdbf5c1 commit 12ad5b5
Show file tree
Hide file tree
Showing 2 changed files with 13 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, since_timestamp, 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 > ?', since_timestamp)
metrics.select('DISTINCT ON (metrics.resource_id) metrics.*')
end
end
5 changes: 5 additions & 0 deletions spec/factories/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
capture_interval_name "realtime"
resource_type "Host"
end

factory :metric_container_node_rt, :parent => :metric, :class => :Metric do
capture_interval_name "realtime"
resource_type "ContainerNode"
end
end

0 comments on commit 12ad5b5

Please sign in to comment.