Use linear version of User#manageable_groups
What does this MR do?
In this method we're switching the behavior of the User#manageable_groups
method to use the linear version. The new behavior is behind the linear_user_manageable_groups
feature flag.
How to setup and validate locally (strongly suggested)
- Enable the new method behavior feature flag
Feature.enable(:linear_user_manageable_groups)
- In rails console enable the traversal id feature flag
Feature.enable(:use_traversal_ids)
SQL queries
The former sql was:
WITH RECURSIVE base_and_descendants AS (
(SELECT namespaces.*
FROM namespaces
INNER JOIN members ON namespaces.id = members.source_id
WHERE members.type = 'GroupMember'
AND members.source_type = 'Namespace'
AND namespaces.type = 'Group'
AND members.user_id = 1
AND members.requested_at IS NULL
AND (access_level >= 10)
AND members.access_level IN (40,
50))
UNION
(SELECT namespaces.*
FROM namespaces,
base_and_descendants
WHERE namespaces.type = 'Group'
AND namespaces.parent_id = base_and_descendants.id))
SELECT namespaces.*
FROM base_and_descendants AS namespaces
The new sql query is:
SELECT namespaces.*
FROM
(SELECT DISTINCT on(namespaces.id) namespaces.*
FROM namespaces,
(SELECT namespaces.id
FROM namespaces
INNER JOIN members ON namespaces.id = members.source_id
WHERE members.type = 'GroupMember'
AND members.source_type = 'Namespace'
AND namespaces.type = 'Group'
AND members.user_id = 1
AND members.requested_at IS NULL
AND (access_level >= 10)
AND members.access_level IN (40,
50)) base
WHERE (namespaces.traversal_ids @> ARRAY[base.id])) namespaces
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Related to #339197 (closed)
Edited by Francisco Javier López