Skip to content

Commit

Permalink
Merge pull request #19022 from d-m-u/make_faster_user_roles
Browse files Browse the repository at this point in the history
Cleanup seed_from_array product feature things
  • Loading branch information
bdunne authored Jul 23, 2019
2 parents eb93c7e + ee5fa62 commit 31e12c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/miq_user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def self.seed
end

def self.seed_from_array(roles, array, merge_features = false)
features = MiqProductFeature.all
array.each do |hash|
feature_ids = hash.delete(:miq_product_feature_identifiers)

hash[:miq_product_features] = MiqProductFeature.where(:identifier => feature_ids).to_a
hash[:miq_product_features] = features.select { |f| feature_ids.include?(f.identifier) }
role = roles[hash[:name]] ||= new(hash.except(:id))
new_role = role.new_record?
hash[:miq_product_features] &&= role.miq_product_features if !new_role && merge_features
unless role.settings.nil? # Makse sure existing settings are merged in with the new ones.
unless role.settings.nil? # Make sure existing settings are merged in with the new ones.
new_settings = hash.delete(:settings) || {}
role.settings.merge!(new_settings)
end
Expand Down

0 comments on commit 31e12c3

Please sign in to comment.