Add GraphQL API for most used runners
What does this MR do and why?
Add GraphQL API for most used runners API for "most used runners" (#437659 - closed)
Based on Add service for calculating most used runners (!142576 - merged)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Follow https://docs.gitlab.com/ee/development/database/clickhouse/clickhouse_within_gitlab.html#gdk-setup up to and including running migrations
- Run the following in the rails console:
::Ci::Build.where.not(finished_at: nil).find_each{|build| ::Ci::FinishedBuildChSyncEvent.upsert({ build_id: build.id, build_finished_at: build.finished_at }, unique_by: [:build_id, :partition]) }
ClickHouse::DataIngestion::CiFinishedBuildsSyncService.new.execute
- visit
-/graphql-explorer
execute the following graphql query
{ runnerUsage(runnerType: INSTANCE_TYPE, fromDate: "2023-01-01", toDate: "2023-12-31", runnersLimit: 3) {
runner {
id
description
}
ciBuildCount
ciMinutesUsed
}}
You should get something like:
{
"data": {
"runnerUsage": [
{
"runner": {
"id": "gid://gitlab/Ci::Runner/24",
"description": "My runner24"
},
"ciBuildCount": 12,
"ciMinutesUsed": 1860
},
{
"runner": {
"id": "gid://gitlab/Ci::Runner/30",
"description": "My runner30"
},
"ciBuildCount": 12,
"ciMinutesUsed": 1860
},
{
"runner": {
"id": "gid://gitlab/Ci::Runner/18",
"description": "My runner18"
},
"ciBuildCount": 11,
"ciMinutesUsed": 1800
},
{
"runner": null,
"ciBuildCount": 225,
"ciMinutesUsed": 24483
}
]
}
}