Expose DORA scores via GraphQL
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
- 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
- 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
for_date_range
SELECT "dora_performance_scores".* FROM "dora_performance_scores" WHERE "dora_performance_scores"."date" BETWEEN '2023-01-01' AND '2023-02-01'
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
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #386844 (closed)