Commit a5b98bf7 authored by Stan Hu's avatar Stan Hu

Merge branch '8911-ls-usage-data' into 'master'

Include 'license_scanning' in Usage data

See merge request gitlab-org/gitlab!23690
parents c38bcf99 d0362748
......@@ -90,10 +90,17 @@ module EE
dast: :dast_jobs,
dependency_scanning: :dependency_scanning_jobs,
license_management: :license_management_jobs,
license_scanning: :license_scanning_jobs,
sast: :sast_jobs
}
results = count(::Ci::Build.where(name: types.keys).group(:name), fallback: Hash.new(-1))
license_scan_count = results.delete("license_scanning")
if license_scan_count && results["license_management"]
results["license_management"] += license_scan_count
end
results.each_with_object({}) { |(key, value), response| response[types[key.to_sym]] = value }
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -18,6 +18,7 @@ describe Gitlab::UsageData do
create(:ci_build, name: 'dast', pipeline: pipeline)
create(:ci_build, name: 'dependency_scanning', pipeline: pipeline)
create(:ci_build, name: 'license_management', pipeline: pipeline)
create(:ee_ci_build, name: 'license_scanning', pipeline: pipeline)
create(:ci_build, name: 'sast', pipeline: pipeline)
create(:prometheus_alert, project: projects[0])
......@@ -118,7 +119,7 @@ describe Gitlab::UsageData do
expect(count_data[:container_scanning_jobs]).to eq(1)
expect(count_data[:dast_jobs]).to eq(1)
expect(count_data[:dependency_scanning_jobs]).to eq(1)
expect(count_data[:license_management_jobs]).to eq(1)
expect(count_data[:license_management_jobs]).to eq(2)
expect(count_data[:sast_jobs]).to eq(1)
end
......
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