Commit 6a18c230 authored by Philip Cunningham's avatar Philip Cunningham Committed by Mark Chao

Add usage ping and index for DAST On-Demand Scans

parent b1070678
---
title: Add usage ping and index for DAST On-Demand Scans
merge_request: 40219
author:
type: added
# frozen_string_literal: true
class AddIndexOnCiPipelinesSourceForOnDemandDast < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_ci_pipelines_for_ondemand_dast_scans'
SOURCE_ONDEMAND_DAST_SCAN_PIPELINE = 13
disable_ddl_transaction!
def up
add_concurrent_index(
:ci_pipelines, :id,
where: "source = #{SOURCE_ONDEMAND_DAST_SCAN_PIPELINE}",
name: INDEX_NAME
)
end
def down
remove_concurrent_index(
:ci_pipelines, :id,
where: "source = #{SOURCE_ONDEMAND_DAST_SCAN_PIPELINE}",
name: INDEX_NAME
)
end
end
d7dd6ef7c39576988d1efd7bb179f75e3104fc8058a671e47c7b68ba2ddc9ba8
\ No newline at end of file
......@@ -19461,6 +19461,8 @@ CREATE UNIQUE INDEX index_ci_pipeline_variables_on_pipeline_id_and_key ON public
CREATE INDEX index_ci_pipelines_config_on_pipeline_id ON public.ci_pipelines_config USING btree (pipeline_id);
CREATE INDEX index_ci_pipelines_for_ondemand_dast_scans ON public.ci_pipelines USING btree (id) WHERE (source = 13);
CREATE INDEX index_ci_pipelines_on_auto_canceled_by_id ON public.ci_pipelines USING btree (auto_canceled_by_id);
CREATE INDEX index_ci_pipelines_on_ci_ref_id ON public.ci_pipelines USING btree (ci_ref_id) WHERE (ci_ref_id IS NOT NULL);
......
......@@ -121,6 +121,10 @@ module EE
results
end
def on_demand_pipelines_usage
{ dast_on_demand_pipelines: count(::Ci::Pipeline.ondemand_dast_scan) }
end
# Note: when adding a preference, check if it's mapped to an attribute of a User model. If so, name
# the base key part after a corresponding User model attribute, use its possible values as suffix values.
override :user_preferences_usage
......@@ -181,6 +185,7 @@ module EE
},
requirements_counts,
security_products_usage,
on_demand_pipelines_usage,
epics_deepest_relationship_level,
operations_dashboard_usage)
end
......
......@@ -28,6 +28,7 @@ RSpec.describe Gitlab::UsageData do
create(:ci_build, name: 'sast', pipeline: pipeline)
create(:ci_build, name: 'secret_detection', pipeline: pipeline)
create(:ci_build, name: 'coverage_fuzzing', pipeline: pipeline)
create(:ci_pipeline, source: :ondemand_dast_scan, project: projects[0])
create(:prometheus_alert, project: projects[0])
create(:prometheus_alert, project: projects[0])
......@@ -145,6 +146,7 @@ RSpec.describe Gitlab::UsageData do
expect(count_data[:sast_jobs]).to eq(1)
expect(count_data[:secret_detection_jobs]).to eq(1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1)
end
it 'gathers group overview preferences usage data', :aggregate_failures do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment