Skip to content

Add Namespace and ProjectStatistics to GraphQL API

Alessio Caiazza requested to merge ac-graphql-stats into master

What does this MR do?

This introduces a new GraphQL query to get namespace from full_path.

The namespace type can expose the projects, it has a parameter to include or not projects in subgroups.

The project type can expose statistics

query

{
  namespace(fullPath: "work") {
    id
    projects(includeSubgroups: true, first: 3, after: "MjU=") {
      edges {
        cursor
        node {
          id
          fullPath
          statistics {
            commitCount
            storageSize
            repositorySize
            lfsObjectsSize
            buildArtifactsSize
            packagesSize
          }
        }
      }
    }
  }
}

result

{
  "data": {
    "namespace": {
      "id": "60",
      "projects": {
        "edges": [
          {
            "cursor": "MjQ=",
            "node": {
              "id": "24",
              "fullPath": "work/TestPage",
              "statistics": {
                "commitCount": 16,
                "storageSize": 337146,
                "repositorySize": 335544,
                "lfsObjectsSize": 0,
                "buildArtifactsSize": 1602,
                "packagesSize": 0
              }
            }
          },
          {
            "cursor": "MjI=",
            "node": {
              "id": "22",
              "fullPath": "work/minimal-ruby-app",
              "statistics": {
                "commitCount": 22,
                "storageSize": 107102,
                "repositorySize": 94371,
                "lfsObjectsSize": 0,
                "buildArtifactsSize": 12731,
                "packagesSize": 0
              }
            }
          },
          {
            "cursor": "MjM=",
            "node": {
              "id": "23",
              "fullPath": "work/test-pages",
              "statistics": {
                "commitCount": 17,
                "storageSize": 123450,
                "repositorySize": 115343,
                "lfsObjectsSize": 0,
                "buildArtifactsSize": 8107,
                "packagesSize": 0
              }
            }
          }
        ]
      }
    }
  }
}

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Alessio Caiazza

Merge request reports