<commit_before>class Group < ActiveRecord::Base
  attr_accessible :name, :poll_ids, :user_ids
  has_and_belongs_to_many :polls
  has_many :group_users
  has_many :users, :through => :group_users

  after_save :update_polls
  def update_polls
    unless poll_ids.nil?
      self.polls do |poll|
        poll.destroy unless poll_ids.include?(poll.id) # first delete all removed groups
      end
    end
  end

  def save_users_by_emails(emails)
    errors = []
    puts "**Saving emails**"
    puts emails
    emails.each do |email|
      user = User.where(email: email)
      if user.present?
        users << user
      else
        errors << "User #{email} not found"
      end
    end
    puts errors
    return errors
  end
end<commit_msg>Added check for blank emails to #save_users_by_email to fix bug<commit_after>class Group < ActiveRecord::Base
  attr_accessible :name, :poll_ids, :user_ids
  has_and_belongs_to_many :polls
  has_many :group_users
  has_many :users, :through => :group_users

  after_save :update_polls
  def update_polls
    unless poll_ids.nil?
      self.polls do |poll|
        poll.destroy unless poll_ids.include?(poll.id) # first delete all removed groups
      end
    end
  end

  def save_users_by_emails(emails)
    errors = []
    puts "**Saving emails**"
    puts emails
    emails.each do |email|
      unless email.blank?
        user = User.where(email: email)
        if user.present?
          users << user
        else
          errors << "User #{email} not found"
        end
      end
    end
    puts errors
    return errors
  end
end
{'fraction_non_alphanumeric': 0.08027812895069532, 'fraction_numerical': 0.0, 'mean_word_length': 2.6474654377880182, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4183352', 'n_tokens_mistral': 511, 'n_tokens_neox': 514, 'n_words': 145}