Remove unused aiMetricsBasic GraphQL field and its aggregation job

What does this MR do and why?

Removes the experimental aiMetricsBasic GraphQL field from groups and projects, together with the cron job that filled its backing table every 5 minutes on every instance. The field was built for a PostgreSQL-based Duo usage dashboard that was abandoned in favor of ClickHouse, and nothing ever queried it, so it is dead code that still costs background work. The ClickHouse-backed aiMetrics field is untouched: the two counts its codeSuggestionMetrics type used to inherit from a removed type are now defined directly on it, so its public API is unchanged.

This is phase 1 of a two-phase removal (#628407). The worker class stays as a no-op for one release so in-flight jobs finish cleanly, and a migration purges the cron entry and any queued jobs. Phase 2 drops the table and deletes the worker class.

Changelog: removed EE: true

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Run a GraphQL query against a group (e.g. via http://gdk.test:3000/-/graphql-explorer) selecting:

    {
      group(fullPath: "gitlab-org") {
        aiMetricsBasic {
          codeSuggestions {
            shownCount
          }
        }
      }
    }

    Confirm the schema rejects aiMetricsBasic as an unknown field.

  2. Query the still-supported field instead:

    {
      group(fullPath: "gitlab-org") {
        aiMetrics {
          codeSuggestions {
            shownCount
            acceptedCount
          }
        }
      }
    }

    Confirm it still validates (ClickHouse is needed for real data; without it the field just returns null, which is expected).

  3. Run migrations and confirm the cron entry is gone:

    bin/rails db:migrate

    Then in a Rails console:

    Sidekiq::Cron::Job.find('analytics_refresh_ai_events_counts_cron_worker')

    This should return nil.

Database

The migration only removes the Sidekiq cron entry and purges queued jobs for the worker. It does not touch the schema.

Migration up
main: == [advisory_lock_connection] object_id: 164440, pg_backend_pid: 9394
main: == 20260909120000 RemoveAiEventsCountAggregationWorkerJobInstances: migrating =
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: == 20260909120000 RemoveAiEventsCountAggregationWorkerJobInstances: migrated (0.0139s) 

main: == [advisory_lock_connection] object_id: 164440, pg_backend_pid: 9394
Migration down
main: == [advisory_lock_connection] object_id: 164420, pg_backend_pid: 8544
main: == 20260909120000 RemoveAiEventsCountAggregationWorkerJobInstances: reverting =
main: == 20260909120000 RemoveAiEventsCountAggregationWorkerJobInstances: reverted (0.0169s) 

main: == [advisory_lock_connection] object_id: 164420, pg_backend_pid: 8544

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.

Related to #628407

Edited by Pavel Shutsin

Merge request reports

Loading
Loading