Skip to content

Create devops adoption measurements

Adam Hegyi requested to merge create-devops-adoption-measurements into master

What does this MR do?

This MR implements the snapshots relation for a segment. A snapshot contains several boolean flags recording which devops features are used by the segment. A segment might consist of several groups.

The MR includes:

  • Moving all models and tests to EE (mistake from a previous MR), this is an EE feature.
  • Add the Snapshot model
  • Expose the latest Snapshot record in GraphQL
  • Preloading logic for taking the latest snapshot, avoiding N+1.
  • GraphQL API change (feature is not in used) to return array of groups (we allow maximum 20 groups so it's safe to load them at once)

How to test it:

  1. Generate data FILTER=devops_adoption rake db:seed_fu
  2. Log in as admin
  3. Go to graphql explorer: http://localhost:3000/-/graphql-explorer
  4. Run the query
query devopsAdoption {
  devopsAdoptionSegments {
    nodes{
      id
      name
      groups {
          id
          name
          webUrl
      }
            
      latestSnapshot {
        issueOpened
        mergeRequestOpened
        mergeRequestApproved
        runnerConfigured
        pipelineSucceeded
        deploySucceeded
        securityScanSucceeded
        recordedAt
      }
    }
  }
}

DB Query

SELECT "analytics_devops_adoption_snapshots".*
FROM "analytics_devops_adoption_snapshots"
INNER JOIN
  (SELECT DISTINCT FIRST_VALUE(id) OVER (PARTITION BY segment_id
                                         ORDER BY recorded_at DESC) AS id
   FROM "analytics_devops_adoption_snapshots"
   WHERE "analytics_devops_adoption_snapshots"."segment_id" IN (11, 12)) latest_snapshots ON latest_snapshots.id = analytics_devops_adoption_snapshots.id

Plan: https://explain.depesz.com/s/xC4E

We'll look up maximum 20 segment_ids.

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
Edited by Adam Hegyi

Merge request reports

Loading