<commit_before># == Schema Information
#
# Table name: newsletter_users
#
#  id                      :integer          not null, primary key
#  email                   :string(255)
#  lang                    :string(255)      default("fr")
#  token                   :string(255)
#  newsletter_user_role_id :integer
#  created_at              :datetime         not null
#  updated_at              :datetime         not null
#
# Indexes
#
#  index_newsletter_users_on_email                    (email) UNIQUE
#  index_newsletter_users_on_newsletter_user_role_id  (newsletter_user_role_id)
#

#
# == NewsletterUser Model
#
class NewsletterUser < ActiveRecord::Base
  include Tokenable
  include Scopable
  include Mailable

  belongs_to :newsletter_user_role

  attr_accessor :nickname # captcha
  attr_accessor :name # name extracted from email

  validates :email,
            presence: true,
            uniqueness: true,
            email_format: true

  validates :lang,
            presence: true,
            allow_blank: false,
            inclusion: { in: I18n.available_locales.map(&:to_s) }

  validates :nickname,
            absence: true

  validates :newsletter_user_role_id,
            presence: true,
            inclusion: { in: NewsletterUserRole.try(:all).try(:map) { |role| role.try(:id) } }

  scope :testers, -> { joins(:newsletter_user_role).where('newsletter_user_roles.kind = ?', 'tester') }
  scope :subscribers, -> { joins(:newsletter_user_role).where('newsletter_user_roles.kind = ?', 'subscriber') }

  delegate :title, :kind, to: :newsletter_user_role, prefix: true, allow_nil: true

  def self.testers?
    !testers.empty?
  end
end<commit_msg>Try to fix bug with not existing table on validation<commit_after># == Schema Information
#
# Table name: newsletter_users
#
#  id                      :integer          not null, primary key
#  email                   :string(255)
#  lang                    :string(255)      default("fr")
#  token                   :string(255)
#  newsletter_user_role_id :integer
#  created_at              :datetime         not null
#  updated_at              :datetime         not null
#
# Indexes
#
#  index_newsletter_users_on_email                    (email) UNIQUE
#  index_newsletter_users_on_newsletter_user_role_id  (newsletter_user_role_id)
#

#
# == NewsletterUser Model
#
class NewsletterUser < ActiveRecord::Base
  include Tokenable
  include Scopable
  include Mailable

  belongs_to :newsletter_user_role

  attr_accessor :nickname # captcha
  attr_accessor :name # name extracted from email

  validates :email,
            presence: true,
            uniqueness: true,
            email_format: true

  validates :lang,
            presence: true,
            allow_blank: false,
            inclusion: { in: I18n.available_locales.map(&:to_s) }

  validates :nickname,
            absence: true

  validates :newsletter_user_role_id,
            presence: true,
            inclusion: { in: proc { NewsletterUserRole.all.map(&:id) } }

  scope :testers, -> { joins(:newsletter_user_role).where('newsletter_user_roles.kind = ?', 'tester') }
  scope :subscribers, -> { joins(:newsletter_user_role).where('newsletter_user_roles.kind = ?', 'subscriber') }

  delegate :title, :kind, to: :newsletter_user_role, prefix: true, allow_nil: true

  def self.testers?
    !testers.empty?
  end
end
{'fraction_non_alphanumeric': 0.09450222882615156, 'fraction_numerical': 0.006537890044576523, 'mean_word_length': 2.5209205020920504, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1215134', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1028, 'n_words': 225}