Skip to content

Expose DORA scores via GraphQL

charlie ablett requested to merge 386844-expose-dora-scores-graphql into master

What does this MR do and why?

Expose DORA scores via GraphQL. In order to access:

  • User must be Reporter or above
  • License must be Ultimate

How to set up and validate locally

  1. Seed some DORA metrics data
score1 = Dora::PerformanceScore.create(project: project, date: Time.current.to_date.beginning_of_month, deployment_frequency: 'high', lead_time_for_changes: 'high', time_to_restore_service: 'medium', change_failure_rate: 'low')
# etc etc
  1. Use the following query
query {
  project(fullPath: "flightjs/Flight") {
    doraScores(startDate: "2023-02-01", endDate: "2023-04-01") {
      nodes {
        date
        deploymentFrequency # low/medium/high/null
        leadTimeForChanges
        timeToRestoreService
        changeFailureRate
      }
    }
  }
}

When querying a group's DORA metrics, you can use by project below (and we avoid N+1s, there is a spec):

query {
  group(fullPath: "flightjs") {
    name
    projects {
      nodes {
      	name
        doraScores(startDate: "2023-02-01", endDate: "2023-04-01") {
          nodes {
            date
            deploymentFrequency # low/medium/high/null
            leadTimeForChanges
            timeToRestoreService
            changeFailureRate
          }
        }
      }
    }
  }
}

Database queries

Two scopes have been added into Dora::PerformanceScore.

for_projects

SELECT "dora_performance_scores".* FROM "dora_performance_scores" WHERE "dora_performance_scores"."project_id" = 9970 👉 https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/18393/commands/60892

for_date_range

SELECT "dora_performance_scores".* FROM "dora_performance_scores" WHERE "dora_performance_scores"."date" BETWEEN '2023-01-01' AND '2023-02-01' 👉 https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/18393/commands/60889

Together:

SELECT "dora_performance_scores".* FROM "dora_performance_scores" WHERE "dora_performance_scores"."date" BETWEEN '2023-01-01' AND '2023-02-01' AND "dora_performance_scores"."project_id" = 9970 👉 https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/18393/commands/60893

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #386844 (closed)

Edited by charlie ablett

Merge request reports

Loading