<commit_before># copy registrants from previous Conventions
class RegistrantCopier
  attr_accessor :subdomain, :previous_id, :registrant_type

  def initialize(registrant_source_string, registrant_type)
    @subdomain, @previous_id = registrant_source_string.split("-")
    @registrant_type = registrant_type
  end

  def registrant
    @registrant ||= Registrant.new(previous_registrant_attributes)
    @registrant.registrant_type = registrant_type
    @registrant
  end

  def contact_detail
    ContactDetail.new(previous_contact_detail_attributes) if previous_contact_detail_attributes.any?
  end

  private

  def previous_registrant_attributes
    attributes = {}
    Apartment::Tenant.switch(subdomain) do
      previous_reg = Registrant.find(previous_id)
      attributes = {
        first_name: previous_reg.first_name,
        middle_initial: previous_reg.middle_initial,
        last_name: previous_reg.last_name,
        birthday: previous_reg.birthday,
        gender: previous_reg.gender
      }
    end
  end

  def previous_contact_detail_attributes
    contact_attributes = {}
    Apartment::Tenant.switch(subdomain) do
      previous_reg = Registrant.find(previous_id)
      if previous_reg.contact_detail.present?
        contact_detail = previous_reg.contact_detail
        [:address,
         :city,
         :state_code,
         :zip,
         :country_residence,
         :country_representing,
         :phone,
         :mobile,
         :email,
         :club,
         :club_contact,
         :organization_member_number,
         :emergency_name,
         :emergency_relationship,
         :emergency_attending,
         :emergency_primary_phone,
         :emergency_other_phone,
         :responsible_adult_name,
         :responsible_adult_phone].each do |attribute|
          contact_attributes[attribute] = contact_detail.send(attribute)
        end
      end
    end
    contact_attributes
  end
end<commit_msg>don't copy emergency contact/responsible_adult fields.<commit_after># copy registrants from previous Conventions
class RegistrantCopier
  attr_accessor :subdomain, :previous_id, :registrant_type

  def initialize(registrant_source_string, registrant_type)
    @subdomain, @previous_id = registrant_source_string.split("-")
    @registrant_type = registrant_type
  end

  def registrant
    @registrant ||= Registrant.new(previous_registrant_attributes)
    @registrant.registrant_type = registrant_type
    @registrant
  end

  def contact_detail
    ContactDetail.new(previous_contact_detail_attributes) if previous_contact_detail_attributes.any?
  end

  private

  def previous_registrant_attributes
    attributes = {}
    Apartment::Tenant.switch(subdomain) do
      previous_reg = Registrant.find(previous_id)
      attributes = {
        first_name: previous_reg.first_name,
        middle_initial: previous_reg.middle_initial,
        last_name: previous_reg.last_name,
        birthday: previous_reg.birthday,
        gender: previous_reg.gender
      }
    end
  end

  def previous_contact_detail_attributes
    contact_attributes = {}
    Apartment::Tenant.switch(subdomain) do
      previous_reg = Registrant.find(previous_id)
      if previous_reg.contact_detail.present?
        contact_detail = previous_reg.contact_detail
        [:address,
         :city,
         :state_code,
         :zip,
         :country_residence,
         :country_representing,
         :phone,
         :mobile,
         :email,
         :club,
         :club_contact,
         :organization_member_number
         ].each do |attribute|
          contact_attributes[attribute] = contact_detail.send(attribute)
        end
      end
    end
    contact_attributes
  end
end
{'fraction_non_alphanumeric': 0.06925357046618162, 'fraction_numerical': 0.0, 'mean_word_length': 3.056830601092896, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6178940', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1076, 'n_words': 189}