-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
Group Gambit Improvements #2192
Conversation
- Use joins instead of looping in group gambit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm globally ok with the approach, but I'm thinking it might be more appropriate to actually use is_numeric to make the difference between a name and ID.
So my suggestions would be, if the identifier is numeric, check IDs. Otherwise, do the check on the names.
That way if the name of a group is a number, those results will not be returned when a program uses the API to return the list of users for a specific other group that has that ID.
It will have the same issues as the current "get user" endpoint, but I think here it makes most sense to have ID return only the correct results, and "name" to be a convenience for the few searches that will be typed by hand https://github.com/flarum/core/blob/master/src/Api/Controller/ShowUserController.php#L51
Then there's just the question of the comma-separated list of identifiers. Either use a loop and do an is_numeric on each identifier before adding it to an orWhere
, or use the first value to apply all of the OR to ids or names.
I hope that makes sense.
Is the goal to avoid groups named "123"? Personally I'd prefer if we could query with a slug instead of an ID, but there's currently no slug mechanism. Maybe I should make a group slug PR first, and then when that's merged we can use that here? |
I think the slug thing needs more discussion before it happens, so I'd suggest making the ID the primary way to use the gambit for now, so that extensions like user-directory can start using it starting next beta even if we don't decide on anything for the slug before then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reading the code, ok for me
Needed for FriendsOfFlarum/user-directory#39
Changes proposed in this pull request:
Confirmed
composer test
).