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

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

  1. Create a project within a group
  2. Seed ai usage data for the project PROJECT_ID=step_1_project FILTER=ai_usage_stats bundle exec rake db:seed_fu
  3. Comment this line to bypass authorization if you are not assigned to a Duo Enterprise seat locally.
  4. 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

Merge request reports

Loading
Loading