<commit_before>class Person < ActiveRecord::Base
  attr_accessible :email, :first_name, :last_name, :public_name, :biography, :company, :avatar

  has_many :event_people, :dependent => :destroy
  has_many :events, :through => :event_people, :uniq => true
  has_many :registrations, :dependent => :destroy

  validates :first_name, :presence => true
  validates :last_name, :presence => true
  validate :biography_limit

  before_create :generate_guid
  before_save :set_public_name

  has_attached_file :avatar,
                    :styles => {:tiny => "16x16>", :small => "32x32>", :large => "128x128>"},
                    :default_url => "person_:style.png"
  validates_attachment_content_type :avatar, :content_type => [/jpg/, /jpeg/, /png/, /gif/]
  def to_s
    if self.public_name.empty?
      self.first_name + " " + self.last_name
    else
      self.public_name
    end
  end

  def withdraw_proposal id
    proposal = self.events.find_by_id(id)
    if !proposal.nil?
      proposal.withdraw
      proposal.save
    end
  end

  def attending_conference? conference
    Registration.where(:conference_id => conference.id,
                       :person_id => self.id).count
  end


  def proposals conference
    self.events.where("conference_id = ? AND state != ? AND state != ? AND event_people.event_role=?", conference.id, "withdrawn", "rejected", "submitter")
  end

  def proposal_count conference
    proposals(conference).count
  end

  def biography_word_count
    if self.biography.nil?
      0
    else
      self.biography.split.size
    end
  end

  def self.find_person_by_user_id user_id
    Person.where(:user_id => user_id).first
  end

  private
  def biography_limit
    if !self.biography.nil? && self.biography.split.size > 150
      errors.add(:abstract, "cannot have more than 150 words")
    end
  end

  def set_public_name
    if public_name.blank?
      self.public_name = "#{first_name} #{last_name}"
    end
  end

  def generate_guid
    begin
      guid = SecureRandom.urlsafe_base64
    end while Person.where(:guid => guid).exists?
    self.guid = guid
  end

end<commit_msg>Don't autogenerate a blank name<commit_after>class Person < ActiveRecord::Base
  attr_accessible :email, :first_name, :last_name, :public_name, :biography, :company, :avatar

  has_many :event_people, :dependent => :destroy
  has_many :events, :through => :event_people, :uniq => true
  has_many :registrations, :dependent => :destroy

  validates :first_name, :presence => true
  validates :last_name, :presence => true
  validate :biography_limit

  before_create :generate_guid
  before_save :set_public_name

  has_attached_file :avatar,
                    :styles => {:tiny => "16x16>", :small => "32x32>", :large => "128x128>"},
                    :default_url => "person_:style.png"
  validates_attachment_content_type :avatar, :content_type => [/jpg/, /jpeg/, /png/, /gif/]
  def to_s
    if self.public_name.empty?
      self.first_name + " " + self.last_name
    else
      self.public_name
    end
  end

  def withdraw_proposal id
    proposal = self.events.find_by_id(id)
    if !proposal.nil?
      proposal.withdraw
      proposal.save
    end
  end

  def attending_conference? conference
    Registration.where(:conference_id => conference.id,
                       :person_id => self.id).count
  end


  def proposals conference
    self.events.where("conference_id = ? AND state != ? AND state != ? AND event_people.event_role=?", conference.id, "withdrawn", "rejected", "submitter")
  end

  def proposal_count conference
    proposals(conference).count
  end

  def biography_word_count
    if self.biography.nil?
      0
    else
      self.biography.split.size
    end
  end

  def self.find_person_by_user_id user_id
    Person.where(:user_id => user_id).first
  end

  private
  def biography_limit
    if !self.biography.nil? && self.biography.split.size > 150
      errors.add(:abstract, "cannot have more than 150 words")
    end
  end

  def set_public_name
    if public_name.blank?
      self.public_name = ""
      self.public_name = "#{first_name} #{last_name}" if !first_name.blank? && !last_name.blank?
    end
  end

  def generate_guid
    begin
      guid = SecureRandom.urlsafe_base64
    end while Person.where(:guid => guid).exists?
    self.guid = guid
  end

end
{'fraction_non_alphanumeric': 0.10792697018719667, 'fraction_numerical': 0.010630922116940143, 'mean_word_length': 3.1179828734538533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '1263283', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1392, 'n_words': 327}