<commit_before># == Schema Information
#
# Table name: users
#
#  id                     :integer          not null, primary key
#  email                  :string           default("")
#  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     :string
#  last_sign_in_ip        :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#  provider               :string
#  uid                    :string
#  first_name             :string
#  last_name              :string
#  username               :string
#  image                  :string
#  location               :string
#  urls                   :text
#

class User < ActiveRecord::Base
  has_many :items

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, omniauth_providers: [:twitter, :facebook]

  serialize :urls, JSON
  validates :first_name, presence: true

  def to_s
    username
  end

  def self.find_or_create_by_omniauth(auth)
    User.where(
      uid: auth[:uid],
      provider: auth[:provider]
    ).first_or_initialize.tap do |user|
      user.assign_attributes(<commit_msg>facebook users may not have username but first_name<commit_after># == Schema Information
#
# Table name: users
#
#  id                     :integer          not null, primary key
#  email                  :string           default("")
#  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     :string
#  last_sign_in_ip        :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#  provider               :string
#  uid                    :string
#  first_name             :string
#  last_name              :string
#  username               :string
#  image                  :string
#  location               :string
#  urls                   :text
#

class User < ActiveRecord::Base
  has_many :items

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, omniauth_providers: [:twitter, :facebook]

  serialize :urls, JSON
  validates :first_name, presence: true

  def to_s
    username.present? ? username : first_name
  end

  def self.find_or_create_by_omniauth(auth)
    User.where(
      uid: auth[:uid],
      provider: auth[:provider]
    ).first_or_initialize.tap do |user|
      user.assign_attributes(
{'fraction_non_alphanumeric': 0.07903673973448595, 'fraction_numerical': 0.0006174745291756715, 'mean_word_length': 2.106423777564717, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4181479', 'n_tokens_mistral': 949, 'n_tokens_neox': 913, 'n_words': 234}