Fix bugs in Groups::AcceptingProjectSharesFinder
What does this MR do and why?
The Groups::AcceptingProjectSharesFinder
currently has a couple of bugs, which this MR tries to address:
- root groups have the ability to set
prevent_sharing_groups_outside_hierarchy
totrue
. When set totrue
, any project in this group should not be allowed to be shared with a group outside this hierarchy. This was not being done, this MR fixes it. - Some groups can be ignored from the final result set automatically. For eg, if the project is already shared with a group, that group should not be shown in the list again. Also, the current group the project is in should not be in the list. The current group's ancestors should not be in the list, because there is no point in inviting an ancestor group to this descendant project.
SQL queries
- when query avoids the current ancestor groups using
NOT IN
.
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" NOT IN (53328385, 65912051) ORDER BY "namespaces"."path" ASC, "namespaces"."id" ASC LIMIT 20 OFFSET 0
Plan: https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/17503/commands/58522
- when query avoids the current ancestor groups using
NOT IN
and also includes only groups within the current hierarchy usingIN
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" IN (65027608, 63522682, 65904858, 63817419, 63839559, 63839659, 65907535, 65904776, 63839605, 65005422, 65907575, 65027555, 65030093, 63839558, 65335934, 64132811, 64733120, 63511936, 65027540, 65323444) AND "namespaces"."id" NOT IN (53328385, 65912051) ORDER BY "namespaces"."path" ASC, "namespaces"."id" ASC LIMIT 20 OFFSET 0
Plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17503/commands/58524
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
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 #393436 (closed)
Edited by Manoj M J