<commit_before># == Schema Information
#
# Table name: people
#
#  id                   :integer          not null, primary key
#  first_name           :string(255)
#  last_name            :string(255)
#  display_name         :string(255)
#  email                :string(255)      not null
#  created_at           :datetime         not null
#  updated_at           :datetime         not null
#  buyer_id             :string(255)
#  password_digest      :string(255)
#  account_completed    :boolean          default(FALSE)
#  paypal_email         :string(255)
#  last_seen_at         :datetime
#  last_bulk_mailed_at  :datetime
#  admin                :boolean          default(FALSE)
#  bio                  :text
#  location             :string(255)
#  url                  :string(255)
#  company              :string(255)
#  public_email         :string(255)
#  accepted_terms_at    :datetime
#  cloudinary_id        :string(255)
#  deleted              :boolean          default(FALSE), not null
#  profile_completed    :boolean          default(FALSE), not null
#  shopping_cart_id     :integer
#  stripe_customer_id   :string(255)
#  suspended_at         :datetime
#  bounty_hunter        :boolean
#  quickbooks_vendor_id :integer
#
# Indexes
#
#  index_people_on_email             (email) UNIQUE
#  index_people_on_shopping_cart_id  (shopping_cart_id)
#

class Person < ActiveRecord::Base
  # temporarily holds a raw access token... useful in controllers-and-views
  attr_accessor :current_access_token

  before_save :format_url

  has_cloudinary_image

  has_paper_trail :only => [:first_name, :last_name, :display_name, :email, :password, :bio, :location, :public_email, :url, :company]

  has_account class_name: 'Account::Personal'
  has_many :orders, -> { where('type LIKE ?', 'Transaction::Order%') }, class_name: 'Transaction'

  has_many :bounty_claims
  has_many :bounty_claim_responses
  has_many :bounty_claim_events
  has_many :access_tokens
  has_many :saved_search_tabs

  # there is no longer a Github::Commit model -- CAB
  # has_many :commits, class_name: 'Github::Commit'
  has_many :fundraisers
  has_many :searches
  has_many :person_relations, class_name: 'PersonRelation::Base'

  has_many :friends,
           class_name:  'Person',
           through:     :person_relations,
           source:      :target_person

  # linked accounts
  has_many :linked_accounts,  class_name: 'LinkedAccount::Base'
  has_one :github_account,    class_name: 'LinkedAccount::Github::User'
  has_one :facebook_account,  class_name: 'LinkedAccount::Facebook'
  has_one :twitter_account,   class_name: 'LinkedAccount::Twitter'

  has_many :tracker_plugins
  has_many :tracker_relations, through: :linked_accounts

  has_many :tag_votes
  has_many :follow_relations

  has_many :team_member_relations
  has_many :teams, through: :team_member_relations

  has_many :pledges
  has_many :bounties
  has_many :team_payins

  has_many :solutions
  has_many :solution_events, through: :solutions

  has_many :language_relations, class_name: 'LanguagePersonRelation'

  has_many :developer_goals

  has_many :activity_logs
  has_many :issue_rank_caches, class_name: 'IssueRankCache'
  has_many :ranked_issues, through: :issue_rank_caches, source: :issue
  has_many :tracker_rank_caches, class_name: 'TrackerRankCache'

  has_many :shopping_carts

  has_many :tracker_person_relations

  has_many :addresses
  has_many :cash_outs
  has_many :proposals
  has_many :thumbs

  has_many :recommendation_events

  has_many :payment_methods
  has_many :support_levels

  has_many :team_bounty_hunters

  has_many :issue_suggestions

  has_many :comments, through: :linked_accounts

  belongs_to :quickbooks_vendor

  EMAIL_REGEX = /\A.+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+\z/

  # all Person objects must have an email address
  validates :email,
            uniqueness: true,
            format: { with: EMAIL_REGEX }

  # if a new password was set, validate it.  if there isn't an encrypted password, require one
  validates :password,
            length: { minimum: 8 },
            format: { with: /[a-z].*[0-9]|[0-9].*[a-z]/i, message: 'must contain a letter and a number' },
            if: 'password_digest.blank? || !password.blank?'

  # NOTE: this only validates if accept is defined (aka: nil is valid)
  validates_acceptance_of :terms, :accept => true
  before_create do
    self.accepted_terms_at = Time.now if self.terms
  end

  has_secure_password

  #validates :paypal_email,
  #          confirmation: true,
  #          format: { with: EMAIL_REGEX },<commit_msg>Validation if no longer supports string, convert to lambda.<commit_after># == Schema Information
#
# Table name: people
#
#  id                   :integer          not null, primary key
#  first_name           :string(255)
#  last_name            :string(255)
#  display_name         :string(255)
#  email                :string(255)      not null
#  created_at           :datetime         not null
#  updated_at           :datetime         not null
#  buyer_id             :string(255)
#  password_digest      :string(255)
#  account_completed    :boolean          default(FALSE)
#  paypal_email         :string(255)
#  last_seen_at         :datetime
#  last_bulk_mailed_at  :datetime
#  admin                :boolean          default(FALSE)
#  bio                  :text
#  location             :string(255)
#  url                  :string(255)
#  company              :string(255)
#  public_email         :string(255)
#  accepted_terms_at    :datetime
#  cloudinary_id        :string(255)
#  deleted              :boolean          default(FALSE), not null
#  profile_completed    :boolean          default(FALSE), not null
#  shopping_cart_id     :integer
#  stripe_customer_id   :string(255)
#  suspended_at         :datetime
#  bounty_hunter        :boolean
#  quickbooks_vendor_id :integer
#
# Indexes
#
#  index_people_on_email             (email) UNIQUE
#  index_people_on_shopping_cart_id  (shopping_cart_id)
#

class Person < ActiveRecord::Base
  # temporarily holds a raw access token... useful in controllers-and-views
  attr_accessor :current_access_token

  before_save :format_url

  has_cloudinary_image

  has_paper_trail :only => [:first_name, :last_name, :display_name, :email, :password, :bio, :location, :public_email, :url, :company]

  has_account class_name: 'Account::Personal'
  has_many :orders, -> { where('type LIKE ?', 'Transaction::Order%') }, class_name: 'Transaction'

  has_many :bounty_claims
  has_many :bounty_claim_responses
  has_many :bounty_claim_events
  has_many :access_tokens
  has_many :saved_search_tabs

  # there is no longer a Github::Commit model -- CAB
  # has_many :commits, class_name: 'Github::Commit'
  has_many :fundraisers
  has_many :searches
  has_many :person_relations, class_name: 'PersonRelation::Base'

  has_many :friends,
           class_name:  'Person',
           through:     :person_relations,
           source:      :target_person

  # linked accounts
  has_many :linked_accounts,  class_name: 'LinkedAccount::Base'
  has_one :github_account,    class_name: 'LinkedAccount::Github::User'
  has_one :facebook_account,  class_name: 'LinkedAccount::Facebook'
  has_one :twitter_account,   class_name: 'LinkedAccount::Twitter'

  has_many :tracker_plugins
  has_many :tracker_relations, through: :linked_accounts

  has_many :tag_votes
  has_many :follow_relations

  has_many :team_member_relations
  has_many :teams, through: :team_member_relations

  has_many :pledges
  has_many :bounties
  has_many :team_payins

  has_many :solutions
  has_many :solution_events, through: :solutions

  has_many :language_relations, class_name: 'LanguagePersonRelation'

  has_many :developer_goals

  has_many :activity_logs
  has_many :issue_rank_caches, class_name: 'IssueRankCache'
  has_many :ranked_issues, through: :issue_rank_caches, source: :issue
  has_many :tracker_rank_caches, class_name: 'TrackerRankCache'

  has_many :shopping_carts

  has_many :tracker_person_relations

  has_many :addresses
  has_many :cash_outs
  has_many :proposals
  has_many :thumbs

  has_many :recommendation_events

  has_many :payment_methods
  has_many :support_levels

  has_many :team_bounty_hunters

  has_many :issue_suggestions

  has_many :comments, through: :linked_accounts

  belongs_to :quickbooks_vendor

  EMAIL_REGEX = /\A.+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+\z/

  # all Person objects must have an email address
  validates :email,
            uniqueness: true,
            format: { with: EMAIL_REGEX }

  # if a new password was set, validate it.  if there isn't an encrypted password, require one
  validates :password,
            length: { minimum: 8 },
            format: { with: /[a-z].*[0-9]|[0-9].*[a-z]/i, message: 'must contain a letter and a number' },
            if: Proc.new { |p| p.password_digest.blank? || !p.password.blank? }

  # NOTE: this only validates if accept is defined (aka: nil is valid)
  validates_acceptance_of :terms, :accept => true
  before_create do
    self.accepted_terms_at = Time.now if self.terms
  end

  has_secure_password

  #validates :paypal_email,
  #          confirmation: true,
  #          format: { with: EMAIL_REGEX },
{'fraction_non_alphanumeric': 0.09084988603060892, 'fraction_numerical': 0.010420058612829698, 'mean_word_length': 3.1635788522367827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2183414', 'n_tokens_mistral': 3166, 'n_tokens_neox': 2988, 'n_words': 694}