Use linear version of User#manageable_groups

Merged Francisco Javier López requested to merge 339197-fj-linear-manageable-groups into master

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)

  1. Enable the new method behavior feature flag
    Feature.enable(:linear_user_manageable_groups)
  2. 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

Related to #339197 (closed)

Edited by Francisco Javier López