-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix container groups\images statistics for all entities
- Loading branch information
Ari Zellner
committed
Aug 24, 2017
1 parent
6d5cb11
commit 1613f75
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
module Metric::Statistic | ||
def self.calculate_stat_columns(obj, timestamp) | ||
return {} unless obj.respond_to?(:container_groups) | ||
return {} unless obj.respond_to?(:container_images) | ||
|
||
capture_interval = Metric::Helper.get_time_interval(obj, timestamp) | ||
container_groups = ContainerGroup.where(:ems_id => obj.id).or(ContainerGroup.where(:old_ems_id => obj.id)) | ||
stats = {} | ||
|
||
if obj.respond_to?(:all_container_groups) | ||
container_groups = obj.all_container_groups # Get disconnected entities as well | ||
stats[:stat_container_group_create_rate] = container_groups.where(:ems_created_on => capture_interval).count | ||
stats[:stat_container_group_delete_rate] = container_groups.where(:deleted_on => capture_interval).count | ||
end | ||
|
||
if obj.respond_to?(:all_container_images) | ||
stats[:stat_container_image_registration_rate] = obj.all_container_images.where(:registered_on => capture_interval).count | ||
end | ||
|
||
{ | ||
:stat_container_group_create_rate => container_groups.where(:ems_created_on => capture_interval).count, | ||
:stat_container_group_delete_rate => container_groups.where(:deleted_on => capture_interval).count, | ||
:stat_container_image_registration_rate => obj.container_images.where(:registered_on => capture_interval).count | ||
} | ||
stats | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters