Skip to content

Expose Devops Adoption segments via GraphQL

Adam Hegyi requested to merge 262395-devops-adoption-read-api into master

What does this MR do?

This MR exposes the instance level segments via GraphQL.

Previous MR: !45748 (merged)

What is a Segment?

A segment (maximum 20 segments) exists on the instance level and it can contain maximum 20 groups or projects (out of scope). These segments will be periodically probed to collect various metrics about the devops adoption.

Example

Create a segment called "GitLab" which contains the following groups:

  • gitlab-org
  • gitlab-com

A periodical process (not part of this MR) will look into the configured groups and stores metrics. Examples:

  • Was there an issue created in the last 30 days? (store boolean flag: the segment adopted issues)
  • Was there an epic created in the last 30 days? (store boolean flag: the segment adopted epics)
  • ...

More info and mockups: #235421 (closed)

Database query for segments

SELECT "analytics_devops_adoption_segments".* FROM "analytics_devops_adoption_segments" ORDER BY "analytics_devops_adoption_segments"."name" ASC;

Plan:

Name is unique and we have a unique index on name.

Index Scan using index_analytics_devops_adoption_segments_on_name on analytics_devops_adoption_segments  (cost=0.15..61.35 rows=880 width=64) (actual time=0.018..0.023 rows=6 loops=1)
 Planning Time: 0.100 ms
 Execution Time: 0.050 ms
(3 rows)

Testing

How to generate some segments?

Console:

5.times { |i| Analytics::DevopsAdoption::Segment.create!(name: "Segment #{i}", segment_selections_attributes: Group.all.shuffle.take(rand(5) + 1).map { |group| { group_id: group.id } })}

To test the mutations locally, navigate to: http://localhost:3000/-/graphql-explorer

Make sure you're logged in as admin.

GraphQL query

Listing segments:

query getSegments {
  devopsAdoptionSegments {
    nodes {
      id
      name
      groups {
        nodes {
          name
          id
          webUrl
        }
      }
    }
  }
}

Does this MR meet the acceptance criteria?

Conformity

Availability 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

Related to #262395 (closed)

Edited by Adam Hegyi

Merge request reports

Loading