<commit_before>class MoveFaxFromOfferToContactPerson < ActiveRecord::Migration
  def change
    add_column :contact_people, :fax_area_code, :string, limit: 6
    add_column :contact_people, :fax_number, :string, limit: 32

    Offer.find_each do |offer|
      empty_contact = offer.contact_people.where(name: "").first
      if empty_contact
        empty_contact.fax_number = offer.fax
        empty_contact.save(validate: false)
      elsif offer.organizations.count > 0
        cp = ContactPerson.new(
          fax_number: offer.fax,
          organization_id: offer.organizations.first.id
        )
        cp.save(validate: false)<commit_msg>improve fax migration to only update when fax is set<commit_after>class MoveFaxFromOfferToContactPerson < ActiveRecord::Migration
  def change
    add_column :contact_people, :fax_area_code, :string, limit: 6
    add_column :contact_people, :fax_number, :string, limit: 32

    Offer.where.not(fax: '').find_each do |offer|
      empty_contact = offer.contact_people.where(name: "").first
      if empty_contact
        empty_contact.fax_number = offer.fax
        empty_contact.save(validate: false)
      elsif offer.organizations.count > 0
        cp = ContactPerson.new(
          fax_number: offer.fax,
          organization_id: offer.organizations.first.id
        )
        cp.save(validate: false)
{'fraction_non_alphanumeric': 0.08936484490398819, 'fraction_numerical': 0.005908419497784343, 'mean_word_length': 3.2476489028213167, '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': '2015027', 'n_tokens_mistral': 429, 'n_tokens_neox': 400, 'n_words': 89}