Pterodactyl4J icon indicating copy to clipboard operation
Pterodactyl4J copied to clipboard

Proper Query Support

Open devnote-dev opened this issue 2 years ago • 2 comments

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?

devnote-dev avatar Dec 12 '22 19:12 devnote-dev

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 avatar Dec 12 '22 20:12 mattmalec

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

mattmalec avatar Dec 12 '22 20:12 mattmalec