<commit_before>module ActiveHashRelation::ColumnFilters
  def model_class_name(resource)
    resource.class.to_s.split('::').first.constantize
  end

  def filter_primary(resource, column, param)
    resource = resource.where(id: param)
  end

  def filter_integer(resource, column, table_name, param)
    if !param.is_a? Hash
      return resource.where(column => param)
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end
  end

  def filter_float(resource, column, table_name, param)
    filter_integer(resource, column, table_name, param)
  end

  def filter_decimal(resource, column, table_name, param)
    filter_integer(resource, column, table_name, param)
  end

  def filter_string(resource, column, table_name, param)
    resource = resource.where("#{table_name}.#{column} ILIKE ?", "%#{param}%")
  end

  def filter_text(resource, column, param)
    return filter_string(resource, column, param)
  end

  def filter_date(resource, column, table_name, param)
    if !param.is_a? Hash
      resource = resource.where(column => param[column])
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end

    return resource
  end

  def filter_datetime(resource, column, table_name, param)
    if !param.is_a? Hash
      resource = resource.where(column => param[column])
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end

    return resource
  end

  def filter_boolean(resource, column, param)
    b_param = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(param)

    resource = resource.where(column => b_param)
  end

  private

  def apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    if param[:leq]
      resource = resource.where("#{table_name}.#{column} <= ?", param[:leq])
    elsif param[:le]
      resource = resource.where("#{table_name}.#{column} < ?", param[:leq])
    end

    if param[:geq]
      resource = resource.where("#{table_name}.#{column} >= ?", param[:geq])
    elsif param[:ge]
      resource = resource.where("#{table_name}.#{column} > ?", param[:geq])
    end

    return resource
  end
end<commit_msg>fix bug on date columns<commit_after>module ActiveHashRelation::ColumnFilters
  def model_class_name(resource)
    resource.class.to_s.split('::').first.constantize
  end

  def filter_primary(resource, column, param)
    resource = resource.where(id: param)
  end

  def filter_integer(resource, column, table_name, param)
    if !param.is_a? Hash
      return resource.where(column => param)
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end
  end

  def filter_float(resource, column, table_name, param)
    filter_integer(resource, column, table_name, param)
  end

  def filter_decimal(resource, column, table_name, param)
    filter_integer(resource, column, table_name, param)
  end

  def filter_string(resource, column, table_name, param)
    resource = resource.where("#{table_name}.#{column} ILIKE ?", "%#{param}%")
  end

  def filter_text(resource, column, param)
    return filter_string(resource, column, param)
  end

  def filter_date(resource, column, table_name, param)
    if !param.is_a? Hash
      resource = resource.where(column => param[column])
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end

    return resource
  end

  def filter_datetime(resource, column, table_name, param)
    if !param.is_a? Hash
      resource = resource.where(column => param[column])
    else
      return apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    end

    return resource
  end

  def filter_boolean(resource, column, param)
    b_param = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(param)

    resource = resource.where(column => b_param)
  end

  private

  def apply_leq_geq_le_ge_filters(resource, table_name, column, param)
    if param[:leq]
      resource = resource.where("#{table_name}.#{column} <= ?", param[:leq])
    elsif param[:le]
      resource = resource.where("#{table_name}.#{column} < ?", param[:le])
    end

    if param[:geq]
      resource = resource.where("#{table_name}.#{column} >= ?", param[:geq])
    elsif param[:ge]
      resource = resource.where("#{table_name}.#{column} > ?", param[:ge])
    end

    return resource
  end
end
{'fraction_non_alphanumeric': 0.1162260711030082, 'fraction_numerical': 0.0, 'mean_word_length': 4.097560975609756, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3821207', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1368, 'n_words': 315}