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

Group filter does not work well #96

Open
ayyilmaz opened this issue Sep 4, 2022 · 1 comment
Open

Group filter does not work well #96

ayyilmaz opened this issue Sep 4, 2022 · 1 comment
Labels

Comments

@ayyilmaz
Copy link

ayyilmaz commented Sep 4, 2022

I think group filter does not work well. Because when I select more than groups it does not show any user.

I selected admins it showed 1 user and then I also selected moderators but it show 0 users. My expectation is that when both are selected, the admin user will be listed even if there is no moderator. Filter use AND operator instead of OR.

Bug Report

Current Behavior
A clear and concise description of the behavior.

Steps to Reproduce

  1. Go to 'user directory page'
  2. Click on 'Filter Group'
  3. Select one group then another groups
  4. when I select more than groups it does not show any user if user is not member of both groups.

Expected Behavior
when both are selected, the admin user will be listed even if there is no moderator. Filter use AND operator instead of OR.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

  • Flarum version: 1.4.01
  • Extension version: x.y.z
  • Website URL: http://example.com
  • Webserver: nginx]
  • Hosting environment: vps
  • PHP version: 8.01
  • Browser: chrome

Possible solution(s)
We should filter with OR operator instead of AND

@ayyilmaz ayyilmaz added the bug label Sep 4, 2022
@clarkwinkelmann
Copy link
Member

This is the currently expected behavior.

The search filter in FoF User Directory maps each criteria to its own token in the q search query, which Flarum automatically translates into an AND query.

params.q += 'group:' + group.id();

Flarum's group: gambit supports providing multiple groups in a single token to perform an OR query https://github.com/flarum/framework/blob/main/framework/core/src/User/Query/GroupFilterGambit.php but this feature is currently not used by User Directory.

I personally think the current implementation makes sense, so I wouldn't want to remove the ability to perform AND queries. But I'm not sure how to accommodate having both AND and OR queries, this would make the UI very complicated.

Another problem is that the javascript search type interface currently used to create custom search properties just doesn't support gambits with multiple criteria, it always matches one item to one gambit/token, with no way to group multiple ones. So that would require some significant refactor.

Also partially of relevance but not directly in this source code, The Taxonomies extension uses the same interface to provide a custom filter. If we change groups to be OR by default, there will be inconsistencies with the other tokens that use AND by default https://github.com/flamarkt/taxonomies/blob/2e2a024b01c4cc3b4daadf4a509e0b6113931b29/js/src/forum/addUserDirectorySearchType.ts#L121

I'm not sure if there are any other extensions extending the available search filters.


A workaround to achieve the filtering you want without changing how the extension works would be to manually type the group:group1,group2 in the search query. I think it will work fine. If this breaks the UI, we can publish a simple fix to make sure multi-criteria gambits aren't parsed by the filter system.

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

No branches or pull requests

2 participants