Add author filter and dimension to MergeRequests aggregation engine

What does this MR do and why?

The DAP Impact Dashboard needs to let leaders filter and group dashboard data by an arbitrary team (a set of people), not only by GitLab group or project. Issue https://gitlab.com/gitlab-org/gitlab/-/issues/611201 is being delivered as four merge requests, one per ClickHouse aggregation engine that was missing by-user support. This MR covers the MergeRequests engine.

The merge_requests table stores author_id as Nullable(Int64), and the engine had no way to filter or group by it. Without this, a team-scoped view of merge requests silently fell back to unfiltered data.

Changes:

  • Adds column :author_id, :integer, description: 'Merge request author', association: { model: ::User } and exact_match :author_id, :string, description: 'Filter by one or many author Global IDs', formatter: gid_formatter to ee/app/models/analytics/aggregation_engines/merge_requests.rb.
  • The dimension name drives model inference in the GraphQL layer: the _id suffix is stripped and the remainder is constantized. Plain association: true would try to resolve a non-existent Author constant, so this dimension passes an explicit association: { model: ::User } instead.
  • This adds a new authorId argument on Analytics.mergeRequests and a new author field of type UserCore on MergeRequestsAggregationResponseDimensions, both generated from the engine declaration.
  • author_id is not part of the table's sort key, so the aggregation framework wraps it in argMax for deduplication, matching how the other non-key columns on this ReplacingMergeTree table are already handled.
  • Nullable column: merge requests with no recorded author group under a null key and the author field resolves to null. Specs cover that case.
  • Also updates the shared spec helper spec/support/helpers/click_house_helpers.rb so insert_merge_requests_to_click_house carries author_id. That helper builds a fixed column set for every row, so this is a single added key.
  • No migration, schema change, or feature flag: the column already existed in ClickHouse.
  • Regenerates doc/api/graphql/reference/_index.md and public/-/graphql/introspection_result.json.
  • Spec coverage: dimension examples for :author_id and the :author association alias (including a row with no author), a filter block for a single Global ID and an array of Global IDs, and a GraphQL request context that filters by an author Global ID and groups by the resolved association.

Out of scope

How to set up and validate locally

  1. Query the new argument and dimension in GraphiQL:

    query {
      group(fullPath: "gitlab-org") {
        analytics {
          mergeRequests(authorId: ["gid://gitlab/User/1"]) {
            aggregated { nodes { dimensions { author { id username } } totalCount } }
          }
        }
      }
    }
  2. Run the specs for this engine:

    bundle exec rspec ee/spec/models/analytics/aggregation_engines/merge_requests_spec.rb ee/spec/requests/api/graphql/analytics/merge_requests_spec.rb
  3. Confirm the GraphQL docs are up to date:

    bundle exec rake gitlab:graphql:check_docs
  4. Confirm the introspection JSON is up to date:

    bundle exec rake gitlab:graphql:check_introspection_sync

References

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.

Merge request reports

Loading
Loading