<commit_before>class User < ActiveRecord::Base
  include SmsNumber
  # include AttrSearchable
  mount_uploader :picture, PictureUploader
  # Include default devise modules. Others available are:
  # :confirmable,
  # :lockable, :timeoutable and :omniauthable, :validatable,
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable,
         :confirmable, :lockable, :timeoutable


  enum role: {inactive: 0, basic: 10, leader: 20, admin: 30}

  # attr_searchable :first_name, :last_name
  # attr_searchable scout: [ 'users.first_name', 'users.last_name']

  has_and_belongs_to_many :units
  has_many :notifiers, dependent: :destroy
  has_and_belongs_to_many :events, -> { uniq }
  belongs_to :sub_unit
  has_many :email_messages, dependent: :destroy
  has_many :sms_messages, dependent: :destroy
  has_and_belongs_to_many :merit_badges

  has_many :counselors, inverse_of: :user, dependent: :destroy, autosave: true do
    def unit(unit_id)
      where(counselors:{unit_id: unit_id})
    end
  end
  has_many :merit_badges, through: :counselors, autosave: true do
    def unit(unit_id)
      where(counselors:{unit_id: unit_id})
    end
  end
  accepts_nested_attributes_for :counselors, reject_if: proc { |att| att['merit_badge_id'].blank? }, allow_destroy: true

  has_many :phones, dependent: :destroy
  accepts_nested_attributes_for :phones, allow_destroy: true, reject_if: proc { |a| a["number"].blank? }

  before_save :update_picture_attributes
  before_create :save_original_filename

  # Setup accessible (or protected) attributes for your model
  # attr_accessible :email, :password, :password_confirmation, :remember_me
  # attr_accessible :first_name, :last_name, :address1, :address2, :city, :state, :zip_code, :time_zone<commit_msg>remove habtm<commit_after>class User < ActiveRecord::Base
  include SmsNumber
  # include AttrSearchable
  mount_uploader :picture, PictureUploader
  # Include default devise modules. Others available are:
  # :confirmable,
  # :lockable, :timeoutable and :omniauthable, :validatable,
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable,
         :confirmable, :lockable, :timeoutable


  enum role: {inactive: 0, basic: 10, leader: 20, admin: 30}

  # attr_searchable :first_name, :last_name
  # attr_searchable scout: [ 'users.first_name', 'users.last_name']

  has_and_belongs_to_many :units
  has_many :notifiers, dependent: :destroy
  has_and_belongs_to_many :events, -> { uniq }
  belongs_to :sub_unit
  has_many :email_messages, dependent: :destroy
  has_many :sms_messages, dependent: :destroy

  has_many :counselors, inverse_of: :user, dependent: :destroy, autosave: true do
    def unit(unit_id)
      where(counselors:{unit_id: unit_id})
    end
  end
  has_many :merit_badges, through: :counselors, autosave: true do
    def unit(unit_id)
      where(counselors:{unit_id: unit_id})
    end
  end
  accepts_nested_attributes_for :counselors, reject_if: proc { |att| att['merit_badge_id'].blank? }, allow_destroy: true

  has_many :phones, dependent: :destroy
  accepts_nested_attributes_for :phones, allow_destroy: true, reject_if: proc { |a| a["number"].blank? }

  before_save :update_picture_attributes
  before_create :save_original_filename

  # Setup accessible (or protected) attributes for your model
  # attr_accessible :email, :password, :password_confirmation, :remember_me
  # attr_accessible :first_name, :last_name, :address1, :address2, :city, :state, :zip_code, :time_zone
{'fraction_non_alphanumeric': 0.10036754311563471, 'fraction_numerical': 0.005089058524173028, 'mean_word_length': 5.363309352517986, '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': '2802497', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1152, 'n_words': 286}