Skip to content

Commit

Permalink
Only create the ChargeableField if we plan to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Aug 7, 2018
1 parent 7b1d5e1 commit b234145
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions db/migrate/20171026103833_add_cores_allocated_rate_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class ChargebackRateDetail < ActiveRecord::Base
end

def up
rate_detail_template = ChargebackRateDetail.where(:description => "Allocated CPU Count").first
return if rate_detail_template.nil? # No rates that need this detail.
rate_detail_template = rate_detail_template.dup

chargeable_field = ChargeableField.find_or_create_by(:metric => "derived_vm_numvcpu_cores",
:description => "Allocated CPU Cores",
:group => "cpu_cores",
:source => "allocated")

rate_detail_template = ChargebackRateDetail.where(:description => "Allocated CPU Count").first
return if rate_detail_template.nil? # No rates that need this detail.
rate_detail_template = rate_detail_template.dup
rate_detail_template.chargeable_field = chargeable_field
rate_detail_template.description = "Allocated CPU Cores"
rate_detail_template.per_unit = "cpu core"
Expand Down

0 comments on commit b234145

Please sign in to comment.