<commit_before># == Schema Information
#
# Table name: users
#
#  id                     :integer          not null, primary key
#  email                  :string           default(""), not null
#  encrypted_password     :string           default(""), not null
#  reset_password_token   :string
#  reset_password_sent_at :datetime
#  remember_created_at    :datetime
#  sign_in_count          :integer          default(0), not null
#  current_sign_in_at     :datetime
#  last_sign_in_at        :datetime
#  current_sign_in_ip     :inet
#  last_sign_in_ip        :inet
#  failed_attempts        :integer          default(0), not null
#  unlock_token           :string
#  locked_at              :datetime
#  sid                    :string           not null
#  name                   :string           not null
#  laboratory             :integer          not null
#  position               :integer          not null
#  phone                  :string           not null
#  address                :string
#  birthday               :datetime
#  role                   :integer          default(0), not null
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#

class User < ActiveRecord::Base
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :lockable

  has_many :cards
  has_many :attends
  has_many :schedules, through: :attends

  LABORATORY = %w(無所属 富永研 林研 八重樫研 垂水研 安藤研 最所研 その他).freeze
  POSITION = %w(なし 会計 所長 副所長 会計 広報 物品 旅行 事務).freeze

  def laboratory_text
    LABORATORY[laboratory.to_i]
  end

  def position_text
    POSITION[position.to_i]
  end

  def is_admin?
    100 <= role
  end

  def schema
    {
      email: email,
      name: name,
      sid: sid,
      laboratory: laboratory_text,
      position: position_text,
      phone: phone
    }
  end
end<commit_msg>saveする前に学籍番号を取得する<commit_after># == Schema Information
#
# Table name: users
#
#  id                     :integer          not null, primary key
#  email                  :string           default(""), not null
#  encrypted_password     :string           default(""), not null
#  reset_password_token   :string
#  reset_password_sent_at :datetime
#  remember_created_at    :datetime
#  sign_in_count          :integer          default(0), not null
#  current_sign_in_at     :datetime
#  last_sign_in_at        :datetime
#  current_sign_in_ip     :inet
#  last_sign_in_ip        :inet
#  failed_attempts        :integer          default(0), not null
#  unlock_token           :string
#  locked_at              :datetime
#  sid                    :string           not null
#  name                   :string           not null
#  laboratory             :integer          not null
#  position               :integer          not null
#  phone                  :string           not null
#  address                :string
#  birthday               :datetime
#  role                   :integer          default(0), not null
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#

class User < ActiveRecord::Base
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :lockable

  has_many :cards
  has_many :attends
  has_many :schedules, through: :attends

  before_save :update_sid

  LABORATORY = %w(無所属 富永研 林研 八重樫研 垂水研 安藤研 最所研 その他).freeze
  POSITION = %w(なし 会計 所長 副所長 会計 広報 物品 旅行 事務).freeze

  def laboratory_text
    LABORATORY[laboratory.to_i]
  end

  def position_text
    POSITION[position.to_i]
  end

  def is_admin?
    100 <= role
  end

  def update_sid
    self.sid = email.split('@').first
  end

  def schema
    {
      email: email,
      name: name,
      sid: sid,
      laboratory: laboratory_text,
      position: position_text,
      phone: phone
    }
  end
end
{'fraction_non_alphanumeric': 0.07070444502209514, 'fraction_numerical': 0.0031193137509747857, 'mean_word_length': 1.764367816091954, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3578739', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1234, 'n_words': 312}