Resolve "Defects with the share with group feature"
What does this MR do?
When a group is invited/shared to collaborate in a group or project, we are counting the members inversely.
As an example:
-
Group A
invitesGroup B
to collaborate. - When we display billable members for
Group A
, we should count the members fromGroup A
andGroup B
. - When we display the members for
Group B
, we should count the members fromGroup B
only. - We accidentally implemented the inverse.
- When we display billable members for
Group A
, we are only counting the members fromGroup A
. - When we display the billable members for
Group B
we are counting the members fromGroup B
andGroup A
.
Also when the groups are invited to collaborate as Guest then the users should not be counted in Gold Plan
Example 1
-
Group I
has 3 users.- Owner O
- Maintainer M
- Guest G
-
Group A
invitesGroup I
withGuest
permissions -
Group A
is Silver plan - In
Group A
(Silver Plan) the billed users includeOwner O
,Maintainer M
andGuest G
fromGroup I
Example 2
-
Group I
has 3 users.- Owner O
- Maintainer M
- Guest G
-
Group B
invitesGroup I
withGuest
permissions -
Group B
is Gold plan. - In
Group B
(Gold Plan) none of the members ofGroup I
are billable because they all haveGuest
permissions withinGroup B
's paid namespace.
This MR will take care of the following defects
- Count users from all the groups being invited to the billed group.
- Check permissions of the invited group and do not include the groups with Guest permission for Gold Group.
Apart from the same 3 queries for fetching the data for members pasted here
The query for Get shared group members
has changed and below is the sample query to fetch the billed user's id from shared group for Gitlab-org group. The explain statement for the below query :- https://explain.depesz.com/s/52yM
SELECT DISTINCT
"members"."user_id"
FROM
"members"
LEFT OUTER JOIN
"users"
ON "members"."user_id" = "users"."id"
WHERE
"members"."type" = 'GroupMember'
AND "members"."source_type" = 'Namespace'
AND "users"."state" = 'active'
AND "members"."requested_at" IS NULL
AND "members"."source_id" IN
(
WITH RECURSIVE "base_and_ancestors" AS
(
(
SELECT
"namespaces".*
FROM
"namespaces"
INNER JOIN
"group_group_links"
ON "group_group_links"."shared_with_group_id" = "namespaces"."id"
WHERE
"namespaces"."type" = 'Group'
AND "group_group_links"."shared_group_id" IN
(
WITH RECURSIVE "base_and_descendants" AS
(
(
SELECT
"namespaces".*
FROM
"namespaces"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."id" = 9970)
UNION
(
SELECT
"namespaces".*
FROM
"namespaces", "base_and_descendants"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."parent_id" = "base_and_descendants"."id")
)
SELECT
"namespaces"."id"
FROM
"base_and_descendants" AS "namespaces"
)
)
UNION
(
SELECT
"namespaces".*
FROM
"namespaces", "base_and_ancestors"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."id" = "base_and_ancestors"."parent_id")
)
SELECT
"namespaces"."id"
FROM
"base_and_ancestors" AS "namespaces"
)
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Closes #213211
Edited by Shreyas Agarwal