diff --git a/app/models/chargeback_container_image.rb b/app/models/chargeback_container_image.rb index 4eb8128ba28..6fd02e7784a 100644 --- a/app/models/chargeback_container_image.rb +++ b/app/models/chargeback_container_image.rb @@ -52,12 +52,13 @@ def self.build_results_for_report_ChargebackContainerImage(options) @data_index.store_path(:container_image, :by_container_id, c.id, c.container_image) end + @unknown_project ||= OpenStruct.new(:id => 0, :name => _('Unknown Project'), :ems_ref => _('Unknown')) build_results_for_report_chargeback(options) end def self.default_key(metric_rollup_record, ts_key) - project = @data_index.fetch_path(:container_project, :by_container_id, metric_rollup_record.resource_id) - image = @data_index.fetch_path(:container_image, :by_container_id, metric_rollup_record.resource_id) + project = self.project(metric_rollup_record) + image = self.image(metric_rollup_record) @options[:groupby] == 'project' ? "#{project.id}_#{ts_key}" : "#{project.id}_#{image.id}_#{ts_key}" end @@ -66,7 +67,7 @@ def self.image(consumption) end def self.project(consumption) - @data_index.fetch_path(:container_project, :by_container_id, consumption.resource_id) + @data_index.fetch_path(:container_project, :by_container_id, consumption.resource_id) || @unknown_project end def self.where_clause(records, _options)