Commit 22b1675c authored by Cameron Swords's avatar Cameron Swords

Secure scan metrics report on all CI jobs

Previously metrics were not reported for non-successful and
retried jobs. This change is made to reduce the load on the database.
parent dc3c0e6c
......@@ -401,10 +401,8 @@ module EE
{}.tap do |secure_jobs|
::Security::Scan.scan_types.each do |name, scan_type|
secure_jobs["#{name}_scans".to_sym] = count(::Security::Scan.joins(:build)
.where(scan_type: scan_type)
.merge(::CommitStatus.latest.success)
.where(time_period), :build_id, start: start, finish: finish)
by_scan_type = ::Security::Scan.where(scan_type: scan_type).where(time_period)
secure_jobs["#{name}_scans".to_sym] = count(by_scan_type, :build_id, start: start, finish: finish)
end
end
end
......
......@@ -598,8 +598,8 @@ RSpec.describe Gitlab::UsageData do
user_sast_jobs: 1,
user_secret_detection_jobs: 1,
user_unique_users_all_secure_scanners: 1,
sast_scans: 0,
dependency_scanning_scans: 4,
sast_scans: 2,
dependency_scanning_scans: 6,
container_scanning_scans: 2,
dast_scans: 0,
secret_detection_scans: 2,
......@@ -625,8 +625,8 @@ RSpec.describe Gitlab::UsageData do
coverage_fuzzing_pipeline: be_within(error_rate).percent_of(0),
api_fuzzing_pipeline: be_within(error_rate).percent_of(0),
user_unique_users_all_secure_scanners: 1,
sast_scans: 0,
dependency_scanning_scans: 2,
sast_scans: 1,
dependency_scanning_scans: 3,
container_scanning_scans: 1,
dast_scans: 0,
secret_detection_scans: 1,
......
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