<commit_before>module Searchlogic
  module ActiveRecord
    # Active Record is pretty inconsistent with how their SQL is constructed. This
    # method attempts to close the gap between the various inconsistencies.
    module Consistency
      def self.included(klass)
        klass.class_eval do
          alias_method_chain :merge_joins, :searchlogic
        end
      end
      
      # In AR multiple joins are sometimes in a single join query, and other times they
      # are not. The merge_joins method in AR should account for this, but it doesn't.
      # This fixes that problem. This way there is one join per string, which allows
      # the merge_joins method to delete duplicates.
      def merge_joins_with_searchlogic(*args)
        joins = merge_joins_without_searchlogic(*args)
        joins = joins.collect { |j| j.is_a?(String) ? j.split("  ") : j }.flatten.uniq
				joins = joins.collect do |j|
					if j.is_a?(String)
						j.gsub(/(.*) ON (.*) = (.*)/) do |m|
							sorted = [$2,$3].sort
							"#{$1} ON #{sorted[0]} = #{sorted[1]}"
						end
					else
						j
					end
				end
      end
    end
  end
end<commit_msg>Changed some tabs to spaces<commit_after>module Searchlogic
  module ActiveRecord
    # Active Record is pretty inconsistent with how their SQL is constructed. This
    # method attempts to close the gap between the various inconsistencies.
    module Consistency
      def self.included(klass)
        klass.class_eval do
          alias_method_chain :merge_joins, :searchlogic
        end
      end
      
      # In AR multiple joins are sometimes in a single join query, and other times they
      # are not. The merge_joins method in AR should account for this, but it doesn't.
      # This fixes that problem. This way there is one join per string, which allows
      # the merge_joins method to delete duplicates.
      def merge_joins_with_searchlogic(*args)
        joins = merge_joins_without_searchlogic(*args)
        joins = joins.collect { |j| j.is_a?(String) ? j.split("  ") : j }.flatten.uniq
        joins = joins.collect do |j|
          if j.is_a?(String)
            j.gsub(/(.*) ON (.*) = (.*)/) do |m|
              sorted = [$2,$3].sort
              "#{$1} ON #{sorted[0]} = #{sorted[1]}"
            end
          else
            j
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08839779005524862, 'fraction_numerical': 0.004249893752656183, 'mean_word_length': 2.2335164835164836, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2756798', 'n_tokens_mistral': 763, 'n_tokens_neox': 690, 'n_words': 247}