Commit c2a30862 authored by Doug Stull's avatar Doug Stull

Combine license mgmt and scanning jobs

- split and rename effort was going on and missed it
parent 0f5efcfc
...@@ -194,7 +194,7 @@ module EE ...@@ -194,7 +194,7 @@ module EE
# Omitted because no user, creator or author associated: `auto_devops_disabled`, `auto_devops_enabled` # Omitted because no user, creator or author associated: `auto_devops_disabled`, `auto_devops_enabled`
# Omitted because not in use anymore: `gcp_clusters`, `gcp_clusters_disabled`, `gcp_clusters_enabled` # Omitted because not in use anymore: `gcp_clusters`, `gcp_clusters_disabled`, `gcp_clusters_enabled`
# rubocop: disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def usage_activity_by_stage_configure(time_period) def usage_activity_by_stage_configure(time_period)
{ {
clusters_applications_cert_managers: ::Clusters::Applications::CertManager.where(time_period).distinct_by_user, clusters_applications_cert_managers: ::Clusters::Applications::CertManager.where(time_period).distinct_by_user,
...@@ -314,14 +314,26 @@ module EE ...@@ -314,14 +314,26 @@ module EE
# container_scanning_jobs, dast_jobs, dependency_scanning_jobs, license_management_jobs, sast_jobs # container_scanning_jobs, dast_jobs, dependency_scanning_jobs, license_management_jobs, sast_jobs
# Once https://gitlab.com/gitlab-org/gitlab/merge_requests/17568 is merged, this might be doable # Once https://gitlab.com/gitlab-org/gitlab/merge_requests/17568 is merged, this might be doable
def usage_activity_by_stage_secure(time_period) def usage_activity_by_stage_secure(time_period)
prefix = 'user_'
results = { results = {
user_preferences_group_overview_security_dashboard: count(::User.active.group_view_security_dashboard.where(time_period)) user_preferences_group_overview_security_dashboard: count(::User.active.group_view_security_dashboard.where(time_period))
} }
SECURE_PRODUCT_TYPES.each_with_object(results) do |(secure_type, type_with_name), response| SECURE_PRODUCT_TYPES.each_with_object(results) do |(secure_type, type_with_name), response|
response["user_#{type_with_name}".to_sym] = distinct_count(::Ci::Build.where(name: secure_type).where(time_period), :user_id) response["#{prefix}#{type_with_name}".to_sym] = distinct_count(::Ci::Build.where(name: secure_type).where(time_period), :user_id)
end end
# handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
combined_license_key = "#{prefix}license_management_jobs".to_sym
license_scan_count = results.delete("#{prefix}license_scanning_jobs".to_sym)
if license_scan_count && results[combined_license_key]
results[combined_license_key] += license_scan_count
end
results
end end
# rubocop:enable CodeReuse/ActiveRecord
end end
end end
end end
......
...@@ -353,7 +353,6 @@ describe Gitlab::UsageData do ...@@ -353,7 +353,6 @@ describe Gitlab::UsageData do
user_dast_jobs: 0, user_dast_jobs: 0,
user_dependency_scanning_jobs: 0, user_dependency_scanning_jobs: 0,
user_license_management_jobs: 0, user_license_management_jobs: 0,
user_license_scanning_jobs: 0,
user_sast_jobs: 0 user_sast_jobs: 0
) )
end 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