<commit_before>class PartnerEnquiryProcessor
  @queue = :signup
  
  # Public: Process new enquiries
  #
  # person  - a hash containing details of the person sending the enquiry.
  #           'name'           => the name of the enquirer
  #           'affiliation'    => the person's organisation
  #           'job_title'      => role
  #           'email'          => email address
  #           'telephone'      => phone number
  # 
  # product - a hash describing the product being enquired about
  #           'name'           => textual name of membership level they have expressed an interest in
  # 
  # comment - a hash describing the comment submitted in the contact form
  #           'text'           => the text content of the comment
  #
  # Returns nil. Queues CRM task creation jobs.
  def self.perform(person, product, comment)
    # Create organisation in CapsuleCRM
    organisation = CapsuleCRM::Organisation.find_all(:q => person['affiliation']).first
    if organisation.nil?
      organisation = CapsuleCRM::Organisation.new(:name => person['affiliation'])
      organisation.save
    end
    # Create person
    contact = organisation.people.find do |p| 
      [p.first_name, p.last_name].compact.join(' ') == person['name']
    end
    if contact.nil?
      contact = CapsuleCRM::Person.new(
        :organisation_id => organisation.id,
        :first_name => person['name'].split(' ', 1)[0],
        :last_name => person['name'].split(' ', 1)[1],
      )
    end
    contact.job_title = person['job_title']
    contact.save
  end
  
end<commit_msg>comment improvement when creating contacts<commit_after>class PartnerEnquiryProcessor
  @queue = :signup
  
  # Public: Process new enquiries
  #
  # person  - a hash containing details of the person sending the enquiry.
  #           'name'           => the name of the enquirer
  #           'affiliation'    => the person's organisation
  #           'job_title'      => role
  #           'email'          => email address
  #           'telephone'      => phone number
  # 
  # product - a hash describing the product being enquired about
  #           'name'           => textual name of membership level they have expressed an interest in
  # 
  # comment - a hash describing the comment submitted in the contact form
  #           'text'           => the text content of the comment
  #
  # Returns nil. Queues CRM task creation jobs.
  def self.perform(person, product, comment)
    # Create organisation in CapsuleCRM
    organisation = CapsuleCRM::Organisation.find_all(:q => person['affiliation']).first
    if organisation.nil?
      organisation = CapsuleCRM::Organisation.new(:name => person['affiliation'])
      organisation.save
    end
    # Find existing contact for this organisation in CapsuleCRM
    contact = organisation.people.find do |p| 
      [p.first_name, p.last_name].compact.join(' ') == person['name']
    end
    # If there is no contact, create a new one
    if contact.nil?
      contact = CapsuleCRM::Person.new(
        :organisation_id => organisation.id,
        :first_name => person['name'].split(' ', 1)[0],
        :last_name => person['name'].split(' ', 1)[1],
      )
    end
    # Update contact with new details
    contact.job_title = person['job_title']
    contact.save
  end
  
end
{'fraction_non_alphanumeric': 0.10302114803625377, 'fraction_numerical': 0.002416918429003021, 'mean_word_length': 2.4310880829015544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3505530', 'n_tokens_mistral': 934, 'n_tokens_neox': 917, 'n_words': 281}