<commit_before>class TransmitPolicyMaintenance
  def execute(request)
      xml = CanonicalVocabulary::MaintenanceSerializer.new(
      Policy.find(request[:policy_id]),
        request[:operation],
        request[:reason],
        request[:affected_enrollee_ids],
        request[:include_enrollee_ids]
      ).serialize
      submit_cv('maintenance', xml, request[:current_user])
  end

  private

  def submit_cv(cv_kind, data, current_user)
    return if Rails.env.test?
    tag = (cv_kind.to_s.downcase == "maintenance") ? "hbx.maintenance_messages" : "hbx.enrollment_messages"
    conn = Bunny.new
    conn.start
    ch = conn.create_channel
    x = ch.default_exchange

    x.publish(
      data,
      :routing_key => "hbx.vocab_validator",
      :reply_to => tag,
      :headers => {
        :file_name => "#{SecureRandom.uuid.gsub('-','')}.xml",
        :submitted_by => current_user
      }
    )
    conn.close
  end
end<commit_msg>Connect to broker based on yaml setting in transmit policy maintenance<commit_after>class TransmitPolicyMaintenance
  def execute(request)
      xml = CanonicalVocabulary::MaintenanceSerializer.new(
      Policy.find(request[:policy_id]),
        request[:operation],
        request[:reason],
        request[:affected_enrollee_ids],
        request[:include_enrollee_ids]
      ).serialize
      submit_cv('maintenance', xml, request[:current_user])
  end

  private

  def submit_cv(cv_kind, data, current_user)
    return if Rails.env.test?
    tag = (cv_kind.to_s.downcase == "maintenance") ? "hbx.maintenance_messages" : "hbx.enrollment_messages"
    conn = Bunny.new(ExchangeInformation.amqp_uri)
    conn.start
    ch = conn.create_channel
    x = ch.default_exchange

    x.publish(
      data,
      :routing_key => "hbx.vocab_validator",
      :reply_to => tag,
      :headers => {
        :file_name => "#{SecureRandom.uuid.gsub('-','')}.xml",
        :submitted_by => current_user
      }
    )
    conn.close
  end
end
{'fraction_non_alphanumeric': 0.12089023773394031, 'fraction_numerical': 0.0, 'mean_word_length': 3.0867768595041323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '4659453', 'n_tokens_mistral': 648, 'n_tokens_neox': 633, 'n_words': 109}