Skip to content

Commit

Permalink
Merge pull request #20136 from lpichler/expose_assigned_tos_for_api
Browse files Browse the repository at this point in the history
Add method assigned_to to ChargebackRate model
  • Loading branch information
gtanzillo authored May 7, 2020
2 parents 98d2ee9 + 2bc6f4d commit 341ece6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/models/chargeback_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ChargebackRate < ApplicationRecord

scope :with_rate_type, ->(rate_type) { where(:rate_type => rate_type) }

virtual_column :assigned_to, :type => :string_set

VALID_CB_RATE_TYPES = ["Compute", "Storage"]
DATASTORE_MAPPING = {'CloudVolume' => 'Storage'}.freeze

Expand Down Expand Up @@ -139,6 +141,16 @@ def default?
super || description == 'Default Container Image Rate'
end

def assigned_to
result = []

tos = get_assigned_tos
tos[:tags].each { |tag| result << {:tag => tag} }
tos[:objects].each { |object| result << {:object => object} }
tos[:labels].each { |label| result << {:label => label} }

result
end
###########################################################

private
Expand Down

0 comments on commit 341ece6

Please sign in to comment.