<commit_before># Name Change Email

class QueuedEmail::NameChange < QueuedEmail
  def name
    get_object(:name, ::Name)
  end

  def description; get_object(:description, ::NameDescription,
                              :allow_nil); end

  def old_name_version
    get_integer(:old_name_version)
  end

  def new_name_version
    get_integer(:new_name_version)
  end

  def old_description_version
    get_integer(:old_description_version)
  end

  def new_description_version
    get_integer(:new_description_version)
  end

  def review_status
    get_string(:review_status).to_sym
  end

  def name_change
    ObjectChange.new(name, old_name_version, new_name_version)
  end

  def desc_change
    ObjectChange.new(description, old_description_version, new_description_version)
  end

  def self.create_email(sender, recipient, name, desc,
                        review_status_changed,
                        force_prev = false)
    result = create(sender, recipient)
    fail "Missing name or description!" if !name && !desc
    if name
      result.add_integer(:name, name.id)
      result.add_integer(:new_name_version, name.version)
      old_version = name.version - ((name.changed? || force_prev) ? 1 : 0)
      result.add_integer(:old_name_version, old_version)
    else
      name = desc.name
      result.add_integer(:name, name.id)
      result.add_integer(:new_name_version, name.version)
      result.add_integer(:old_name_version, name.version)
    end
    if desc
      result.add_integer(:description, desc.id)
      result.add_integer(:new_description_version, desc.version)
      old_version = desc.version - ((desc.changed? || force_prev) ? 1 : 0)
      result.add_integer(:old_description_version, old_version)
      result.add_string(:review_status, review_status_changed ? desc.review_status : :no_change)
    else<commit_msg>Fix deprecation warnings triggered by queued_email/name_change.rb<commit_after># Name Change Email

class QueuedEmail::NameChange < QueuedEmail
  def name
    get_object(:name, ::Name)
  end

  def description; get_object(:description, ::NameDescription,
                              :allow_nil); end

  def old_name_version
    get_integer(:old_name_version)
  end

  def new_name_version
    get_integer(:new_name_version)
  end

  def old_description_version
    get_integer(:old_description_version)
  end

  def new_description_version
    get_integer(:new_description_version)
  end

  def review_status
    get_string(:review_status).to_sym
  end

  def name_change
    ObjectChange.new(name, old_name_version, new_name_version)
  end

  def desc_change
    ObjectChange.new(description, old_description_version, new_description_version)
  end

  def self.create_email(sender, recipient, name, desc,
                        review_status_changed,
                        force_prev = false)
    result = create(sender, recipient)
    fail "Missing name or description!" if !name && !desc
    if name
      result.add_integer(:name, name.id)
      result.add_integer(:new_name_version, name.version)
      old_version = name.version - ((name.saved_changes? || force_prev) ? 1 : 0)
      result.add_integer(:old_name_version, old_version)
    else
      name = desc.name
      result.add_integer(:name, name.id)
      result.add_integer(:new_name_version, name.version)
      result.add_integer(:old_name_version, name.version)
    end
    if desc
      result.add_integer(:description, desc.id)
      result.add_integer(:new_description_version, desc.version)
      old_version = desc.version - ((desc.saved_changes? || force_prev) ? 1 : 0)
      result.add_integer(:old_description_version, old_version)
      result.add_string(:review_status, review_status_changed ? desc.review_status : :no_change)
    else
{'fraction_non_alphanumeric': 0.0843501326259947, 'fraction_numerical': 0.002122015915119363, 'mean_word_length': 3.4574468085106385, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1351856', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1123, 'n_words': 228}