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

Proper Query Support #64

Open
devnote-dev opened this issue Dec 12, 2022 · 2 comments
Open

Proper Query Support #64

devnote-dev opened this issue Dec 12, 2022 · 2 comments

Comments

@devnote-dev
Copy link

Currently, field-specific queries for resources are implemented in retrieveXByY methods which don't actually use the filter or sort params. This is an issue especially for methods such as retrieveUsersByUsername() as you are not guaranteed to receive the expected results due to the use of manual filtering.

Consider this example: the API returns user objects ordered by their ID, so user 1's username may be "Dev", user 2 is "Joe", etc. But you want to list all users with username "Matt", using retrieveUsersByUsername() will only return users that appear within the first 50 results which does not guarantee that you will get all the Matts, even less so if there are 50+ users in the panel.

This can be fixed by implementing a way to specify query options for requests in the retrieve methods, or changing the retrieveXByY methods to use the filter/sort params. WDYT?

@mattmalec
Copy link
Owner

mattmalec commented Dec 12, 2022

retrieveUsersByUsername should paginate over all the users, and then filter.

I was working on a PR that properly implements filters and sorts by having FilterablePteroAction and SortablePteroAction where you could chain filters and sorts to your calls, and then the retrieveUsersByUsername would just wrap this stuff for convenience and backwards compatibility.

The manual filtering will still return the same result, it's just considerably slower. If you had 3000 users, and named Matt, you'd have to paginate over all of those vs. just filtering and getting a list of the 3 Matt's in a single API call

@mattmalec
Copy link
Owner

I believe I have a local branch where I was hacking on this, but it got super long and enterprise Java feely due to the way I was handling generics for it

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

2 participants