<commit_before>require 'rubygems'
require 'rest_client'
require 'builder'
require 'active_support/all'

module Helpmeout
  class Service
    
    def add_fix(failed_test)
      RestClient.post 'http://blooming-frost-23.heroku.com/fixes', generate_fix_xml(failed_test), :content_type => :xml unless failed_test.failed_test_files.empty?
    end

    def query_fix(backtrace, exception_classname, exception_message)
      response = RestClient.post('http://blooming-frost-23.heroku.com/fixes/find', :params => {:backtrace => clean_backtrace(backtrace).join("\n"), :exception_classname => exception_classname, :code_line => code_line_from_backtrace(backtrace), :exception_message => exception_message})
      Hash.from_xml response
    end

    private 
    def generate_fix_xml(failed_test)
      xml = Builder::XmlMarkup.new( :indent => 2 )
      xml.instruct!
      xml.fix do |f|
        f.exception_message failed_test.exception_message
        f.exception_classname failed_test.exception_classname
        f.backtrace clean_backtrace(failed_test.backtrace)
        if failed_test.failed_test_files.any? 
          f.fix_files_attributes do |ffa|<commit_msg>changed params for finding fixes<commit_after>require 'rubygems'
require 'rest_client'
require 'builder'
require 'active_support/all'

module Helpmeout
  class Service
    
    def add_fix(failed_test)
      RestClient.post 'http://blooming-frost-23.heroku.com/fixes', generate_fix_xml(failed_test), :content_type => :xml unless failed_test.failed_test_files.empty?
    end

    def query_fix(backtrace, exception_classname, exception_message)
      response = RestClient.post('http://blooming-frost-23.heroku.com/fixes/find', {:backtrace => clean_backtrace(backtrace).join("\n"), :exception_classname => exception_classname, :code_line => code_line_from_backtrace(backtrace), :exception_message => exception_message})
      Hash.from_xml response
    end

    private 
    def generate_fix_xml(failed_test)
      xml = Builder::XmlMarkup.new( :indent => 2 )
      xml.instruct!
      xml.fix do |f|
        f.exception_message failed_test.exception_message
        f.exception_classname failed_test.exception_classname
        f.backtrace clean_backtrace(failed_test.backtrace)
        if failed_test.failed_test_files.any? 
          f.fix_files_attributes do |ffa|
{'fraction_non_alphanumeric': 0.09931212381771282, 'fraction_numerical': 0.004299226139294927, 'mean_word_length': 4.252821670428894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '481671', 'n_tokens_mistral': 733, 'n_tokens_neox': 718, 'n_words': 126}