Loading
Add aiMetricsBasic endpoint to GraphQL
What does this MR do and why?
Add aiMetricsBasic GraphQL endpoint for projects and groups
to support metrics with Postgresql datasource.
This endpoint behavior is analogous to the CH aiMetrics, but for now, only
contains code suggestions shown/accepted to support acceptance rate calculation.
References
For Database reviewers
- Query plans https://console.postgres.ai/gitlab/joe-instances/255](https://console.postgres.ai/gitlab/gitlab-production-main/sessions/44216/commands/135388
The query above queries for a whole month of accepted events sum for GitLab.org group. This is the worst-case scenario for the query.
How to set up and validate locally
- Create a project within a group
- Seed ai usage data for the project
PROJECT_ID=step_1_project FILTER=ai_usage_stats bundle exec rake db:seed_fu - Comment this line to bypass authorization if you are not assigned to a Duo Enterprise seat locally.
- Run the queries introduced by the MR:
query GetAiMetricsBasic($fullPath: ID!, $startDate: Date!, $endDate: Date!) {
group(fullPath: $fullPath) {
aiMetricsBasic(startDate: $startDate, endDate: $endDate) {
codeSuggestions {
shownCount
acceptedCount
}
}
}
}
query GetAiMetricsBasic($fullPath: ID!, $startDate: Date!, $endDate: Date!) {
project(fullPath: $fullPath) {
aiMetricsBasic(startDate: $startDate, endDate: $endDate) {
codeSuggestions {
shownCount
acceptedCount
}
}
}
}
Sample variables
{
"fullPath": "toolbox",
"startDate": "2025-10-01",
"endDate": "2025-10-31"
}
Check if the values match
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Felipe Cardozo