Advanced user search: Add namespace filtering
What does this MR do and why?
- Performs simple filtering when a group or project is selected.
- Enables group and project level advanced user searches behind a feature flag.
Filter requirements
Group filtering
For a group x
with namespaces y
and z
, a user must match either:
- A prefix on the full namespace i.e.
z-y-x-
- Any exact term of ancestors i.e.
z-y-
orz-
Project filtering
For a project A
in group x
with namespaces y
and z
, a user must match either:
- The exact term of the project namespace ancestry i.e.
z-y-x-pA-
- Any exact term of the project's ancestors i.e.
z-y-x-
,z-y-
orz-
Implementation
Change UserClassProxy
when a project or group is selected to:
- Get the namespace's ancestry
- Break it up into ancestor parts
- For projects: a
terms
query onnamespace_ancestry_ids
with the project's full ancestry and ancestor parts. - For groups:
- a
prefix
query onnamespace_ancestry_ids
with the group's full ancestry. - a
terms
query onnamespace_ancestry_ids
with ancestor parts.
- a
Result
Groups
Users who are members
of the following are valid:
- The selected group
- Descendants of the selected group
- Projects belonging to descendants of the selected group
- Any of the selected groups' ancestors
Projects
Users who are members
of the following are valid:
- The selected project
- The selected project's group
- Any of the selected project's group's ancestors
* NOT the project's group's descendants
Screenshots or screen recordings
Group filtering:
Project filtering:
How to set up and validate locally
- Make sure elasticsearch is running
- Enable advanced user search:
Feature.enable(:advanced_user_search)
- Navigate to the web app and do a search without selecting a group. This should show all matching users
- Select a group. Verify that the users returned are members of the group, its ancestors or descendants, or descendant's projects
- Select a project. Verify that the users returned are members of the project, its group, or the group's ancestors
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #387503 (closed)
Edited by Madelein van Niekerk