<commit_before>class RoleRight < ActiveRecord::Base
  include MultiTenant
  validates :role_id, :right_id, presence: true
  validates :role_id, uniqueness: { scope: [:right_id, :group_id] }

  has_one :roles
  has_one :rights

  def self.provision(root_id, new_group_id)
    roots = RoleRight.unscope(:where).where('group_id = ?', root_id)
    if (roots.size > 0)
      roots.to_a.each do |r|
        rr = RoleRight.new
        rr.role_id = r.role_id
        rr.right_id = r.right_id
        rr.group_id = new_group_id
        rr.save
      end
    else
      err_msg = 'No role_rights records found for group id #{root_id}'
      raise Exception, err_msg
    end
  end

end<commit_msg>Fix issue when no role rights are defined<commit_after>class RoleRight < ActiveRecord::Base
  include MultiTenant
  validates :role_id, :right_id, presence: true
  validates :role_id, uniqueness: { scope: [:right_id, :group_id] }

  has_one :roles
  has_one :rights

  def self.provision(root_id, new_group_id)
    roots = RoleRight.unscope(:where).where('group_id = ?', root_id)
    if (roots.size > 0)
      roots.to_a.each do |r|
        rr = RoleRight.new
        rr.role_id = r.role_id
        rr.right_id = r.right_id
        rr.group_id = new_group_id
        rr.save
      end
    end
  end

end
{'fraction_non_alphanumeric': 0.09852598913886734, 'fraction_numerical': 0.0015515903801396431, 'mean_word_length': 2.8392857142857144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925287', 'n_tokens_mistral': 481, 'n_tokens_neox': 457, 'n_words': 109}