Skip to content

Commit

Permalink
Merge pull request #14811 from zeari/fix_nil_project_cb_report
Browse files Browse the repository at this point in the history
chargeback - group results with unknown project under 'unknown project'
(cherry picked from commit d573adc)
  • Loading branch information
isimluk authored and simaishi committed Apr 20, 2017
1 parent 14e0654 commit 005d38d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/models/chargeback_container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,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

Expand All @@ -58,7 +59,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)
Expand Down

0 comments on commit 005d38d

Please sign in to comment.