Commit 9f2f97be authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'id-approval-rules-usage-ping' into 'master'

Add number of approval project rules to usage ping

See merge request gitlab-org/gitlab!36316
parents 37456cb6 5da4b718
---
title: Add number of approval project rules to usage ping
merge_request: 36316
author:
type: added
......@@ -662,6 +662,8 @@ appear to be associated to any of the services running, since they all appear to
| `projects_with_repositories_enabled` | `usage_activity_by_stage` | `create` | | EE | |
| `protected_branches` | `usage_activity_by_stage` | `create` | | EE | |
| `suggestions` | `usage_activity_by_stage` | `create` | | EE | |
| `approval_project_rules` | `usage_activity_by_stage` | `create` | | EE | Number of project approval rules |
| `approval_project_rules_with_target_branch` | `usage_activity_by_stage` | `create` | | EE | Number of project approval rules with not default target branch |
| `clusters` | `usage_activity_by_stage` | `monitor` | | CE+EE | |
| `clusters_applications_prometheus` | `usage_activity_by_stage` | `monitor` | | CE+EE | |
| `operations_dashboard_default_dashboard` | `usage_activity_by_stage` | `monitor` | | CE+EE | |
......
# frozen_string_literal: true
# Model for join table between ApprovalProjectRule and ProtectedBranch
class ApprovalProjectRulesProtectedBranch < ApplicationRecord
end
......@@ -97,6 +97,13 @@ module EE
end
# rubocop: disable CodeReuse/ActiveRecord
def approval_rules_counts
{
approval_project_rules: count(ApprovalProjectRule),
approval_project_rules_with_target_branch: count(ApprovalProjectRulesProtectedBranch, :approval_project_rule_id)
}
end
def service_desk_counts
projects_with_service_desk = ::Project.where(service_desk_enabled: true)
......@@ -223,7 +230,7 @@ module EE
:author_id,
start: user_minimum_id,
finish: user_maximum_id)
})
}, approval_rules_counts)
end
# Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links`
......
......@@ -301,7 +301,7 @@ RSpec.describe Gitlab::UsageData do
end
context 'for create' do
it 'includes accurate usage_activity_by_stage data' do
it 'includes accurate usage_activity_by_stage data', :aggregate_failures do
for_defined_days_back do
user = create(:user)
project = create(:project, :repository_private, :github_imported,
......@@ -310,7 +310,9 @@ RSpec.describe Gitlab::UsageData do
create(:project, creator: user)
create(:project, creator: user, disable_overriding_approvers_per_merge_request: true)
create(:project, creator: user, disable_overriding_approvers_per_merge_request: false)
create(:protected_branch, project: project)
create(:approval_project_rule, project: project)
protected_branch = create(:protected_branch, project: project)
create(:approval_project_rule, protected_branches: [protected_branch], project: project)
create(:suggestion, note: create(:note, project: project))
create(:code_owner_rule, merge_request: merge_request, approvals_required: 3)
create(:code_owner_rule, merge_request: merge_request, approvals_required: 7)
......@@ -319,6 +321,8 @@ RSpec.describe Gitlab::UsageData do
end
expect(described_class.uncached_data[:usage_activity_by_stage][:create]).to include(
approval_project_rules: 4,
approval_project_rules_with_target_branch: 2,
projects_enforcing_code_owner_approval: 0,
merge_requests_with_optional_codeowners: 4,
merge_requests_with_required_codeowners: 8,
......@@ -328,6 +332,8 @@ RSpec.describe Gitlab::UsageData do
suggestions: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:create]).to include(
approval_project_rules: 4,
approval_project_rules_with_target_branch: 2,
projects_enforcing_code_owner_approval: 0,
merge_requests_with_optional_codeowners: 2,
merge_requests_with_required_codeowners: 4,
......
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