Add author dimension to Contributions 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, since team boundaries do not always map cleanly to a 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 Contributions engine.
The contributions_new table already stores author_id (Int64, not nullable, and part of the table sort key), and the engine already had an author_id exact match filter. Only the dimension was missing, so contributions could be narrowed to a team but never broken down per person. This is the smallest of the four MRs, adding a single dimension declaration.
Changes:
- Adds
column :author_id, :integer, description: 'Contribution author', association: { model: ::User }toee/app/models/analytics/aggregation_engines/contributions.rb. - Because the response field and batch loader are generated from the dimension declaration, this adds a new
authorfield of typeUserCoreonContributionsAggregationResponseDimensions. No new argument is needed, sinceAnalytics.contributions(authorId:)already existed. - The dimension name drives model inference in the GraphQL layer: the
_idsuffix is stripped and the remainder is constantized. Plainassociation: truewould try to resolve a non-existentAuthorconstant, so this dimension passes an explicitassociation: { model: ::User }instead. author_idis part of the sort key, so it does not need theargMaxwrapping that the aggregation framework applies to non-key columns for deduplication.- No migration, schema change, or feature flag: the column already existed in ClickHouse, this only closes a gap in the engine declaration.
- Regenerates
doc/api/graphql/reference/_index.mdandpublic/-/graphql/introspection_result.json. - Spec coverage: adds dimension examples for
:author_idand the:authorassociation alias, plus a GraphQL request context that filters by an author Global ID and groups by the resolved association.
Out of scope
- The
user_usernamefilter work, tracked in #599750. - The
DuoWorkflowsengine, tracked in https://gitlab.com/gitlab-org/gitlab/-/issues/605529, which will ship with by-user filtering and grouping from day one. - The other three engines needing the same treatment (
Deployments,MergeRequests,Pipelines), each covered by its own MR against https://gitlab.com/gitlab-org/gitlab/-/issues/611201.
How to set up and validate locally
-
Query the new dimension in GraphiQL:
query { group(fullPath: "gitlab-org") { analytics { contributions(authorId: ["gid://gitlab/User/1"]) { aggregated { nodes { dimensions { author { id username } } totalCount } } } } } } -
Run the specs for this engine:
bundle exec rspec ee/spec/models/analytics/aggregation_engines/contributions_spec.rb ee/spec/requests/api/graphql/analytics/contributions_spec.rb -
Confirm the GraphQL docs are up to date:
bundle exec rake gitlab:graphql:check_docs -
Confirm the introspection JSON is up to date:
bundle exec rake gitlab:graphql:check_introspection_sync
References
- Part of https://gitlab.com/gitlab-org/gitlab/-/issues/611201
- Epic https://gitlab.com/groups/gitlab-org/-/work_items/23225
- Related: #599750
- Related: https://gitlab.com/gitlab-org/gitlab/-/issues/605529
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.