Commit ca854a2d authored by Allison Browne's avatar Allison Browne Committed by Peter Leitzen

Reformat usage data for shorter lines

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