Skip to content

Add total builds count to external pipeline validation service payload

What does this MR do and why?

This MR adds the number of jobs in alive pipelines created by a user across all projects to the payload of the external pipeline validation service.

Issue: https://gitlab.com/gitlab-org/modelops/anti-abuse/pipeline-validation-service/-/issues/129

Queries

Postgres.ai link: https://console.postgres.ai/shared/e88095e9-5ce6-4dd0-bf6b-fd83395e6049

Raw SQL
SELECT
  *
FROM
  "ci_pipelines"
  INNER JOIN "ci_builds" ON "ci_builds"."commit_id" = "ci_pipelines"."id"
  AND "ci_builds"."type" = 'Ci::Build'
WHERE
  "ci_pipelines"."user_id" = 4018056
  AND "ci_pipelines"."created_at" > '2022-08-08 11:29:32.225441'
  AND (
    "ci_pipelines"."status" IN (
      'waiting_for_resource',
      'preparing',
      'pending',
      'running',
      'created'
    )
  )
Plan
 Nested Loop  (cost=1.13..999.73 rows=4 width=1604) (actual time=0.018..0.018 rows=0 loops=1)
   Buffers: shared hit=3
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ci_pipelines_on_user_id_and_id_and_cancelable_status on public.ci_pipelines  (cost=0.43..10.02 rows=1 width=334) (actual time=0.016..0.016 rows=0 loops=1)
         Index Cond: (ci_pipelines.user_id = 4018056)
         Filter: ((ci_pipelines.created_at > '2022-08-08 11:29:32.225441'::timestamp without time zone) AND ((ci_pipelines.status)::text = ANY ('{waiting_for_resource,preparing,pending,running,created}'::text[])))
         Rows Removed by Filter: 0
         Buffers: shared hit=3
         I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ci_builds_on_commit_id_and_status_and_type on public.ci_builds  (cost=0.70..982.30 rows=741 width=1270) (actual time=0.000..0.000 rows=0 loops=0)
         Index Cond: ((ci_builds.commit_id = ci_pipelines.id) AND ((ci_builds.type)::text = 'Ci::Build'::text))
         I/O Timings: read=0.000 write=0.000

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Alex Buijs

Merge request reports

Loading