Skip to content

Commit

Permalink
Use kind_of? for checking type and remove unnecessary var
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Nov 28, 2016
1 parent 506c4ee commit 70bd693
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/chargeback/rates_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def get(perf)
@rates ||= {}
@rates[perf.hash_features_affecting_rate] ||=
ChargebackRate.get_assigned_for_target(perf.resource,
:tag_list => perf.tag_list_reconstruct,
:tag_list => perf.tag_list_with_prefix,
:parents => perf.parents_determining_rate)
end
end
Expand Down
12 changes: 5 additions & 7 deletions app/models/metric/chargeback_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ def tag_prefix
klass_prefix + TAG_MANAGED_PREFIX
end

def tag_list_reconstruct
tag_list = tag_names

if resource_type == Container.name
def tag_list_with_prefix
if resource.kind_of?(Container)
state = resource.vim_performance_state_for_ts(timestamp.to_s)
tag_list += state.image_tag_names if state.present?
image_tag_name = "#{state.image_tag_names}|" if state
end
tag_list.split("|").map { |tag| "#{tag_prefix}#{tag}" }

"#{image_tag_name}#{tag_names}".split("|").reject(&:empty?).map { |x| "#{tag_prefix}#{x}" }
end

def resource_parents
Expand Down

0 comments on commit 70bd693

Please sign in to comment.