<commit_before>module IndexFilter
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods

    def has_index_filters(methods = {})
      define_method('create_filter_and_conditions_objects') do
        @filter = params[:filter] unless @filter
        @conditions = [' 1 = 1 '] unless @conditions
      end

      define_method('add_conditions') do
        unless @filter.blank?
          methods.keys.each do |method|
            logger.info "argument: #{method}"
            unless @filter[method].blank?
              case methods[method]
                when :like then
                  @conditions[0] << " AND #{method.to_s} LIKE ? "
                  @conditions << "%#{@filter[method]}%"
                when :equal then
                  @conditions[0] << " AND #{method.to_s} = ? "
                  @conditions << "#{@filter[method]}"
              end
            end
            logger.info "conditions: #{@conditions}"
          end
        end
      end

      instance_eval('private :create_filter_and_conditions_objects')
      instance_eval('private :add_conditions')
      instance_eval('before_filter :create_filter_and_conditions_objects, :only => :index')<commit_msg>added new logical operators for conditions <, <=, >, >=<commit_after>module IndexFilter
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods

    def has_index_filters(methods = {})
      define_method('create_filter_and_conditions_objects') do
        @filter = params[:filter] unless @filter
        @conditions = [' 1 = 1 '] unless @conditions
      end

      define_method('add_conditions') do
        unless @filter.blank?
          methods.keys.each do |method| logger.info "argument: #{method}"
            unless @filter[method].blank?
              case methods[method]
                when :like then
                  @conditions[0] << " AND #{method.to_s} LIKE ? "
                  @conditions << "%#{@filter[method]}%"
                when :equal then
                  @conditions[0] << " AND #{method.to_s} = ? "
                  @conditions << "#{@filter[method]}"
                when :greater then
                  @conditions[0] << " AND #{method.to_s} > ? "
                  @conditions << "#{@filter[method]}"
                when :less then
                  @conditions[0] << " AND #{method.to_s} < ? "
                  @conditions << "#{@filter[method]}"
                when :greater_or_equal then
                  @conditions[0] << " AND #{method.to_s} >= ? "
                  @conditions << "#{@filter[method]}"
                when :less_or_equal then
                  @conditions[0] << " AND #{method.to_s} <= ? "
                  @conditions << "#{@filter[method]}"
              end
            end
            logger.info "conditions: #{@conditions}"
          end
        end
      end

      instance_eval('private :create_filter_and_conditions_objects')
      instance_eval('private :add_conditions')
      instance_eval('before_filter :create_filter_and_conditions_objects, :only => :index')
{'fraction_non_alphanumeric': 0.12410887880751782, 'fraction_numerical': 0.0038885288399222295, 'mean_word_length': 1.956896551724138, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 9, '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': '6771975', 'n_tokens_mistral': 847, 'n_tokens_neox': 806, 'n_words': 175}