Code Monkey home page Code Monkey logo

filterer's People

Contributors

ajb avatar beerlington avatar olliebennett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

filterer's Issues

Rails 5 - to_hash is deprecated

DEPRECATION WARNING: Method to_hash is deprecated and will be removed in Rails 5.1, as `ActionController::Parameters` no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited. Instead, consider using one of these documented methods which are not deprecated: http://api.rubyonrails.org/v5.0.0.1/classes/ActionController/Parameters.html

Baked in limit / offset?

I wanted to be able to filter what my API returns and I used filterer to do this. I was surprised to see that there was a limit of 10. I was able to find the code in filterer that does this and it does not seem like it can be overriden. Is my use case of the Filterer gem valid? Or should it not be used for an API?

Usage of "chain" and "filter" in Ruby 2.6

Ruby 2.6.0 was released this week, and introduces Enumerator::Chain and Enumerable#filter.

The filterer gem already implements the chain and filter methods on an ActiveRecord collection.

On older rubies (<2.6) everything works fine;

# Ruby 2.5.x
> User.where('1=1').chain
=> [#<User:0x00007fe8bbf5f9c3 ... etc as expected.

However, on new rubies (>2.6.0) we see the following problem;

# Ruby 2.6.0
> User.where('1=1').chain
=> #<Enumerator::Chain: ...>

It seems the simplest solution is to rename or avoid the .chain and .filter methods in this gem.

Thoughts?

Using filterer without pagination

I like the way filterer makes it easy to pass params and get the result without having a bunch of ifs. However, I don't always use it for an API -- sometimes I use it in some service object to allow fellow developers pass in options that are in turn used in the filterer object. The problem is that I don't want pagination for this. Is there a way to use filterer without pagination?

Not using `present_params`

I want to create a filterer that only returns results from all fields match. For example, let's say I want to get the results of only the records that both match the age and rank. If only age is given, it will return nothing. If only rank is given, it will return nothing.

I had thought of setting defaults to {age: nil, rank: nil} (yes, this will only work if neither of those fields can be nil), but noticed that present_params checks for values that are present?. This would also disallow people from searching for values that match "" (blank).

What issues would removing present_params cause? I did a cursory search in the git history but couldn't find the reason that method is there.

per_page causing error where string is compared to fixnum

This happens because per_page, when given in the params, is a string. I have a branch that fixes it here. I didn't create a pull request because there's no "0_4_x" branch to merge it into. Note: this branch is from v0.4.2. I took a quick look at master and I think master is susceptible to this issue too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.