Commit c19a273b authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '207409-status-page-usage-ping' into 'master'

Status Page Usage Ping

See merge request gitlab-org/gitlab!28002
parents af2bc548 ca854a2d
......@@ -327,6 +327,8 @@ but commented out to help encourage others to add to it in the future. -->
|dependency_scanning_jobs|counts||
|license_management_jobs|counts||
|sast_jobs|counts||
|status_page_projects|counts|monitor|
|status_page_issues|counts|monitor|
|epics_deepest_relationship_level|counts||
|operations_dashboard_default_dashboard|counts||
|operations_dashboard_users_with_projects_added|counts||
......
......@@ -25,6 +25,7 @@ module EE
issue_ids = EpicIssue.where(epic_id: epics).select(:issue_id)
id_in(issue_ids)
end
scope :on_status_page, -> { joins(project: :status_page_setting).where(status_page_settings: { enabled: true }).public_only }
scope :counts_by_health_status, -> { reorder(nil).group(:health_status).count }
has_one :epic_issue
......
---
title: Add Usage Ping For Status Page
merge_request: 28002
author:
type: added
......@@ -140,28 +140,31 @@ module EE
override :system_usage_data
def system_usage_data
super.tap do |usage_data|
usage_data[:counts].merge!({
dependency_list_usages_total: ::Gitlab::UsageCounters::DependencyList.usage_totals[:total],
epics: count(::Epic),
feature_flags: count(Operations::FeatureFlag),
geo_nodes: count(::GeoNode),
ldap_group_links: count(::LdapGroupLink),
ldap_keys: count(::LDAPKey),
ldap_users: count(::User.ldap, 'users.id'),
pod_logs_usages_total: ::Gitlab::UsageCounters::PodLogs.usage_totals[:total],
projects_enforcing_code_owner_approval: count(::Project.without_deleted.non_archived.requiring_code_owner_approval),
merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional, :merge_request_id),
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required, :merge_request_id),
projects_mirrored_with_pipelines_enabled: count(::Project.mirrored_with_enabled_pipelines),
projects_reporting_ci_cd_back_to_github: count(::GithubService.without_defaults.active),
projects_with_packages: distinct_count(::Packages::Package, :project_id),
projects_with_tracing_enabled: count(ProjectTracingSetting),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
},
service_desk_counts,
security_products_usage,
epics_deepest_relationship_level,
operations_dashboard_usage)
usage_data[:counts].merge!(
{
dependency_list_usages_total: ::Gitlab::UsageCounters::DependencyList.usage_totals[:total],
epics: count(::Epic),
feature_flags: count(Operations::FeatureFlag),
geo_nodes: count(::GeoNode),
ldap_group_links: count(::LdapGroupLink),
ldap_keys: count(::LDAPKey),
ldap_users: count(::User.ldap, 'users.id'),
pod_logs_usages_total: ::Gitlab::UsageCounters::PodLogs.usage_totals[:total],
projects_enforcing_code_owner_approval: count(::Project.without_deleted.non_archived.requiring_code_owner_approval),
merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional, :merge_request_id),
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required, :merge_request_id),
projects_mirrored_with_pipelines_enabled: count(::Project.mirrored_with_enabled_pipelines),
projects_reporting_ci_cd_back_to_github: count(::GithubService.without_defaults.active),
projects_with_packages: distinct_count(::Packages::Package, :project_id),
projects_with_tracing_enabled: count(ProjectTracingSetting),
status_page_projects: count(::StatusPageSetting.enabled),
status_page_issues: count(::Issue.on_status_page),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
},
service_desk_counts,
security_products_usage,
epics_deepest_relationship_level,
operations_dashboard_usage)
end
end
......
......@@ -41,6 +41,13 @@ describe Gitlab::UsageData do
# for group_view testing
create(:user) # user with group_view = NULL (should be counted as having default value 'details')
create(:user, group_view: :details)
# Status Page
create(:status_page_setting, project: projects[0], enabled: true)
create(:status_page_setting, project: projects[1], enabled: false)
# 1 public issue on 1 projects with status page enabled
create(:issue, project: projects[0])
create(:issue, :confidential, project: projects[0])
end
subject { described_class.data }
......@@ -93,6 +100,8 @@ describe Gitlab::UsageData do
projects_with_prometheus_alerts
projects_with_tracing_enabled
sast_jobs
status_page_projects
status_page_issues
design_management_designs_create
design_management_designs_update
design_management_designs_delete
......@@ -105,6 +114,8 @@ describe Gitlab::UsageData do
expect(count_data[:projects_with_prometheus_alerts]).to eq(2)
expect(count_data[:projects_with_packages]).to eq(2)
expect(count_data[:feature_flags]).to eq(1)
expect(count_data[:status_page_projects]).to eq(1)
expect(count_data[:status_page_issues]).to eq(1)
end
it 'has integer value for epic relationship level' do
......
......@@ -77,6 +77,27 @@ describe Issue do
end
end
describe '.on_status_page' do
context 'with public issue and private issue' do
let_it_be(:status_page_setting) { create(:status_page_setting, enabled: true) }
let_it_be(:public_issue) { create(:issue, project: status_page_setting.project) }
let_it_be(:private_issue) { create(:issue, :confidential, project: status_page_setting.project) }
it { expect(Issue.on_status_page.count).to eq(1) }
it { expect(Issue.on_status_page.first).to eq(public_issue) }
end
context 'with project status page settings enabled and disabled' do
let_it_be(:status_page_setting_enabled) { create(:status_page_setting, enabled: true) }
let_it_be(:status_page_setting_disabled) { create(:status_page_setting, enabled: false) }
let_it_be(:issue_with_enabled_project) { create(:issue, project: status_page_setting_enabled.project) }
let_it_be(:issue_with_disabled_project) { create(:issue, project: status_page_setting_disabled.project) }
it { expect(Issue.on_status_page.count).to eq(1) }
it { expect(Issue.on_status_page.first).to eq(issue_with_enabled_project) }
end
end
context 'epics' do
let_it_be(:epic1) { create(:epic) }
let_it_be(:epic2) { create(:epic) }
......
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