Skip to content

Commit

Permalink
Add uniqueness for generation chargeback report for SSUI
Browse files Browse the repository at this point in the history
Chargeback report in summary dashboard screen is calculated
from data from this API request:
/api/services?expand=resources&filter[]=service_id%3Dnil&attributes=chargeback_report

and this request is returing data from each service

service1:
  chargeback_data_for_service_my_service

service2:
  chargeback_data_for_service_my_service

service3:
  chargeback_data_for_service_my_service

but for each service has been used
same name of report because Services could be
named by same name.

So when there is generated result for service3 and
this result is empty then in final API request
will have all services empty result as well because
report results from service1 and 2 have been
overwriten by empty result from service 3 -
thanks to the distiguishing by just name.

So I am adding Service#id for distiguishing and
ensuring uniqueness.
  • Loading branch information
lpichler committed Mar 5, 2018
1 parent 6dd7809 commit dfed1c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ def self.queue_chargeback_reports(options = {})
end

def chargeback_report_name
"Chargeback-Vm-Monthly-#{name}"
"Chargeback-Vm-Monthly-#{name}-#{id}"
end

def generate_chargeback_report(options = {})
_log.info("Generation of chargeback report for service #{name} started...")
_log.info("Generation of chargeback report for service #{name} with #{id} started...")
MiqReportResult.where(:name => chargeback_report_name).destroy_all
report = MiqReport.new(chargeback_yaml)
options[:report_sync] = true
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@

describe "#chargeback_report_name" do
it "creates chargeback report's name" do
expect(@service.chargeback_report_name).to eq "Chargeback-Vm-Monthly-Test_Service_1"
expect(@service.chargeback_report_name).to eq "Chargeback-Vm-Monthly-Test_Service_1-#{@service.id}"
end
end

Expand Down

0 comments on commit dfed1c2

Please sign in to comment.