Added filtering support to ProjectPipelineStatisticsResolver

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

Feat: Added filtering support to ProjectPipelineStatisticsResolver

  • "source" and "branch" are now passed to the resolver and used to filter the pipelines
  • Added filtering to clickhouse query in collect_pipeline_analytics_service

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
image image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Go to the shell in your GDK gitlab directory and run bundle exec rake "gitlab:seed:runner_fleet". This will seed your GDK with some runners and jobs required for testing this MR.

  2. In the GDK console, create ClickHouse sync events for the new pipelines:

    Ci::FinishedPipelineChSyncEvent.insert_all(Ci::Pipeline.preload(:project).finished.where.not(finished_at: nil).order(finished_at: :asc).map { |pipeline| { project_namespace_id: pipeline.project.project_namespace_id, pipeline_id: pipeline.id, pipeline_finished_at: pipeline.finished_at, processed: false } }, unique_by: [:pipeline_id, :partition]);
  3. In the GDK console, import the pipelines referred to by those sync events into ClickHouse:

    Ci::ClickHouse::DataIngestion::FinishedPipelinesSyncService.new.execute
  4. In http://gdk.test:3000/-/graphql-explorer, run the following script:

    {
      project(
        fullPath: "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1"
      ) {
        id
        pipelineAnalytics(source: API, ref: "main") {
          aggregate {
            label
            count
            successCount: count(status: SUCCESS)
            failedCount: count(status: FAILED)
            otherCount: count(status: OTHER)
          }
        }
      }
    }

Related to #454311 (closed)

Merge request reports

Loading