<commit_before>class PersonWithRemoteFields < SimpleDelegator
  REMOTE_FIELDS = [
    :email, :phone, :first_name, :last_name, :is_volunteer,
    :employer, :occupation, :skills, :tags
  ]
  LOCAL_FIELDS = [
    :email, :phone, :first_name, :last_name,
    :address, :city, :zip, :is_volunteer
  ]

  def self.find_or_build(attributes)
    # code duplicated from Person to be extracted into new PersonConstructor
    # class
    search_values = attributes.symbolize_keys.slice(:uuid, :email, :phone).compact

    search_values.each do |search_key, search_value|
      case search_key
        when :email then search_value.downcase!
        when :phone then search_value = PhonyRails.normalize_number(search_value, default_country_code: 'US')
      end
      @person = Person.find_by({search_key => search_value})
      break if @person.present?
    end

    new(@person || Person.new, attributes)
  end

  def initialize(person, attributes)<commit_msg>add state_abbrev to LOCAL_FIELDS in PersonWithRemoteFields<commit_after>class PersonWithRemoteFields < SimpleDelegator
  REMOTE_FIELDS = [
    :email, :phone, :first_name, :last_name, :is_volunteer,
    :employer, :occupation, :skills, :tags
  ]
  LOCAL_FIELDS = [
    :email, :phone, :first_name, :last_name,
    :address, :city, :state_abbrev, :zip, :is_volunteer
  ]

  def self.find_or_build(attributes)
    # code duplicated from Person to be extracted into new PersonConstructor
    # class
    search_values = attributes.symbolize_keys.slice(:uuid, :email, :phone).compact

    search_values.each do |search_key, search_value|
      case search_key
        when :email then search_value.downcase!
        when :phone then search_value = PhonyRails.normalize_number(search_value, default_country_code: 'US')
      end
      @person = Person.find_by({search_key => search_value})
      break if @person.present?
    end

    new(@person || Person.new, attributes)
  end

  def initialize(person, attributes)
{'fraction_non_alphanumeric': 0.09877800407331976, 'fraction_numerical': 0.0, 'mean_word_length': 4.025575447570333, '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': '3857396', 'n_tokens_mistral': 647, 'n_tokens_neox': 623, 'n_words': 147}