Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional filter statements in list #15

Open
dweebo opened this issue Sep 13, 2020 · 4 comments
Open

Allow additional filter statements in list #15

dweebo opened this issue Sep 13, 2020 · 4 comments

Comments

@dweebo
Copy link
Contributor

dweebo commented Sep 13, 2020

I would like to be able to filter people by created_date in order to find new activists.

I started a branch to add an optional filter parameter to list but realized it gets complicated quickly. Multiple filter options with and and or are supported. For example

filter=(email_address eq '[email protected]' or email_address eq '[email protected]') and created_date lt '2018-01-01'

Before I get too far wanted to get your thoughts on how you'd like to support this (if at all).
I see that the special method People#find_by_email uses filtering, so some possible options are

  • add another special method People#find_created_since(Date)
  • add a generic filter parameter to list but support just a single field (that is the path I started down)
  • add a generic filter parameter to list that supports multiple fields and joins with and and or

I'm happy to contribute this feature, just wanted to get feedback before working on it.

@woodhull
Copy link
Member

I'm not familiar with the details in ActionNetwork around this, do you have a pointer for the relevant docs? I found this https://actionnetwork.org/docs/v2/people but I don't see the filter bit.

Filter could just be an arbitrary string (moving all of the filter building complexity to the consumer) or we could try and build out a nice query building interface in ruby -- that seems tricky to do well though.

@woodhull
Copy link
Member

Working backwards: what would the ideal ruby ergonomics be like in a perfect world? Something like arel feels hard to pull off, but maybe I'm wrong about that.

@dweebo
Copy link
Contributor Author

dweebo commented Sep 14, 2020

https://actionnetwork.org/docs/v2#odata has some details, that is where I first saw how to do filtering. Then I searched around for OData multiple filters and found some examples of using and/or syntax like I showed in my example.

Good point about just allowing arbitrary string filtering, I did consider that briefly as well but forgot to include it in my list of options. I don't love it... but that would certainly be easiest!

I've just started using ActionNetwork within the past week, and never used OData before, so certainly not well-versed yet!
I haven't used arel much either but looking briefly at docs don't quite see how that would work.

I like your idea of thinking thru how it would work with idiomatic ruby, as long as this doesn't become too complex. I'm more of a ruby hacker so not sure the best way forward off the top of my head. I know just enough to get by and not cause too much trouble when I am working with ruby 😄 .

@joe-irving
Copy link
Contributor

Not sure if you have seen but it looks like there is already an oData ruby library here. I guess the simplest thing would be to use that to generate query strings?

Potentially worth adding a raw_filter parameter to #list to allow people to do simple filtering for now with just a oData filter string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants