Skip to content
Snippets Groups Projects

Add new fields to GroupType

Merged Abdul Wadood requested to merge 420702-graphql-group-type-fields into master

What does this MR do and why?

This is part of the ongoing Organization work by the grouptenant scale group. Read the blueprint to learn more https://docs.gitlab.com/ee/architecture/blueprints/organization/index.html.

Fields introduced are:

  • descendantGroupsCount
  • groupMembersCount
  • projectsCount

Query plans

  1. https://console.postgres.ai/gitlab/gitlab-production-main/sessions/24623/commands/78338
Raw Query
SELECT COUNT(projects) AS "count_projects", "namespaces"."id" AS "namespaces_id"
FROM "namespaces"
         LEFT OUTER JOIN "projects" ON "projects"."archived" != TRUE AND "projects"."namespace_id" = "namespaces"."id"
WHERE "namespaces"."type" = 'Group'
  AND "namespaces"."id" IN
      (1755573, 1761696, 1793858, 1819570, 1920469, 2287432, 2351283, 2452873, 2593421, 2639717, 2750817, 2843837,
       2907304, 3345373, 3455548, 3887963, 3910297, 3925021, 3930213, 3952433)
GROUP BY "namespaces"."id";
  1. https://console.postgres.ai/gitlab/gitlab-production-main/sessions/24623/commands/78337
Raw Query
SELECT COUNT(members) AS "count_members", "namespaces"."id" AS "namespaces_id"
FROM "namespaces"
         LEFT OUTER JOIN "members" ON "members"."source_type" = 'Namespace' AND "members"."requested_at" IS NULL AND
                                      "members"."access_level" != 5 AND "members"."source_id" = "namespaces"."id" AND
                                      "members"."type" = 'GroupMember'
WHERE "namespaces"."type" = 'GROUP'
  AND "namespaces"."id" IN
      (1755573, 1761696, 1793858, 1819570, 1920469, 2287432, 2351283, 2452873, 2593421, 2639717, 2750817, 2843837,
       2907304, 3345373, 3455548, 3887963, 3910297, 3925021, 3930213, 3952433)
GROUP BY "namespaces"."id";
  1. https://console.postgres.ai/gitlab/gitlab-production-main/sessions/24623/commands/78336
Raw Query
SELECT COUNT(children_namespaces) AS "count_children_namespaces", "namespaces"."id" AS "namespaces_id"
FROM "namespaces"
         LEFT OUTER JOIN "namespaces" "children_namespaces" ON "children_namespaces"."type" = 'Group' AND
                                                               "children_namespaces"."parent_id" = "namespaces"."id"
WHERE "namespaces"."type" = 'Group'
  AND "namespaces"."id" IN
      (1755573, 1761696, 1793858, 1819570, 1920469, 2287432, 2351283, 2452873, 2593421, 2639717, 2750817, 2843837,
       2907304, 3345373, 3455548, 3887963, 3910297, 3925021, 3930213, 3952433)
GROUP BY "namespaces"."id";

How to set up and validate locally

Run the following query on GraphiQL https://gdk.test:3000/-/graphql-explorer:

Query
{
  organization(id: "gid://gitlab/Organizations::Organization/1") {
    id
    path
    groups(sort: NAME_DESC) {
      edges {
        node {
          id
          descendantGroupsCount
          groupMembersCount
          projectsCount
        }
      }
    }
  }
}
Output
{
  "data": {
    "organization": {
      "id": "gid://gitlab/Organizations::Organization/1",
      "path": "default",
      "groups": {
        "edges": [
          {
            "node": {
              "id": "gid://gitlab/Group/35",
              "descendantGroupsCount": 0,
              "groupMembersCount": 5,
              "projectsCount": 2
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/31",
              "descendantGroupsCount": 0,
              "groupMembersCount": 5,
              "projectsCount": 1
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/27",
              "descendantGroupsCount": 0,
              "groupMembersCount": 5,
              "projectsCount": 1
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/24",
              "descendantGroupsCount": 0,
              "groupMembersCount": 4,
              "projectsCount": 2
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/33",
              "descendantGroupsCount": 0,
              "groupMembersCount": 5,
              "projectsCount": 1
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/29",
              "descendantGroupsCount": 0,
              "groupMembersCount": 5,
              "projectsCount": 1
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/109",
              "descendantGroupsCount": 0,
              "groupMembersCount": 1,
              "projectsCount": 0
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/110",
              "descendantGroupsCount": 0,
              "groupMembersCount": 1,
              "projectsCount": 0
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/108",
              "descendantGroupsCount": 1,
              "groupMembersCount": 1,
              "projectsCount": 0
            }
          },
          {
            "node": {
              "id": "gid://gitlab/Group/107",
              "descendantGroupsCount": 2,
              "groupMembersCount": 1,
              "projectsCount": 0
            }
          }
        ]
      }
    }
  }
}

Related to #420702 (closed)

Edited by Abdul Wadood

Merge request reports

Merged results pipeline #1108405366 passed

Pipeline: GitLab

#1108413056

    Pipeline: E2E GDK

    #1108419700

      Merged results pipeline passed for d7846950

      Test coverage 82.51% (15.67%) from 2 jobs

      Merged by Leonardo da RosaLeonardo da Rosa 1 year ago (Dec 15, 2023 2:54pm UTC)

      Loading

      Pipeline #1108483567 failed

      Pipeline failed for db64313a on master

      Test coverage 66.89% (15.67%) from 2 jobs
      10 environments impacted.

      Activity

      Filter activity
      • Approvals
      • Assignees & reviewers
      • Comments (from bots)
      • Comments (from users)
      • Commits & branches
      • Edits
      • Labels
      • Lock status
      • Mentions
      • Merge request status
      • Tracking
    • Leonardo da Rosa removed review request for @l.rosa

      removed review request for @l.rosa

    • Doug Stull requested review from @l.rosa

      requested review from @l.rosa

    • James Fargher approved this merge request

      approved this merge request

    • James Fargher removed review request for @proglottis

      removed review request for @proglottis

    • Leonardo da Rosa approved this merge request

      approved this merge request

    • Leonardo da Rosa resolved all threads

      resolved all threads

    • Leonardo da Rosa enabled an automatic merge when the pipeline for 98a7d0fd succeeds

      enabled an automatic merge when the pipeline for 98a7d0fd succeeds

    • Leonardo da Rosa canceled the automatic merge

      canceled the automatic merge

    • Doug Stull added 1415 commits

      added 1415 commits

      Compare with previous version

    • Doug Stull resolved all threads

      resolved all threads

    • Leonardo da Rosa resolved all threads

      resolved all threads

    • Leonardo da Rosa enabled an automatic merge when the pipeline for d7846950 succeeds

      enabled an automatic merge when the pipeline for d7846950 succeeds

    • Hello @abdwdd 👋

      The database team is looking for ways to improve the database review process and we would love your help!

      If you'd be open to someone on the database team reaching out to you for a chat, or if you'd like to leave some feedback asynchronously, just post a reply to this comment mentioning:

      @gitlab-org/database-team

      And someone will be by shortly!

      Thanks for your help!

      This message was generated automatically. You're welcome to improve it.

    • Leonardo da Rosa mentioned in commit db64313a

      mentioned in commit db64313a

    • Drew Blessing mentioned in commit 3a11d488

      mentioned in commit 3a11d488

    • Doug Stull mentioned in merge request !139966 (merged)

      mentioned in merge request !139966 (merged)

    • added workflowstaging label and removed workflowcanary label

    • Doug Stull mentioned in commit 71f41019

      mentioned in commit 71f41019

    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Loading
    • Please register or sign in to reply
      Loading