Commit cbc85e43 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'telemetry_issue_366' into 'master'

Add requirements created to usage data

See merge request gitlab-org/gitlab!30538
parents 504fc45d 0a42e735
......@@ -233,6 +233,7 @@ but commented out to help encourage others to add to it in the future. -->
|protected_branches|counts||
|releases|counts||
|remote_mirrors|counts||
|requirements_created|counts||
|snippets|counts||
|suggestions|counts||
|todos|counts||
......
......@@ -82,6 +82,14 @@ module EE
usage_data
end
def requirements_counts
return {} unless ::License.feature_available?(:requirements)
{
requirements_created: count(RequirementsManagement::Requirement)
}
end
# rubocop: disable CodeReuse/ActiveRecord
def service_desk_counts
return {} unless ::License.feature_available?(:service_desk)
......@@ -160,6 +168,7 @@ module EE
status_page_issues: count(::Issue.on_status_page),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
},
requirements_counts,
service_desk_counts,
security_products_usage,
epics_deepest_relationship_level,
......
......@@ -7,7 +7,7 @@ describe Gitlab::UsageData do
allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false)
end
describe '#data' do
describe '.data' do
# using Array.new to create a different creator User for each of the projects
let_it_be(:projects) { Array.new(3) { create(:project, :repository, creator: create(:user, group_view: :security_dashboard)) } }
let(:count_data) { subject[:counts] }
......@@ -152,7 +152,7 @@ describe Gitlab::UsageData do
end
end
describe '#features_usage_data_ee' do
describe '.features_usage_data_ee' do
subject { described_class.features_usage_data_ee }
it 'gathers feature usage data of EE' do
......@@ -162,7 +162,7 @@ describe Gitlab::UsageData do
end
end
describe '#license_usage_data' do
describe '.license_usage_data' do
subject { described_class.license_usage_data }
it 'gathers license data' do
......@@ -180,6 +180,28 @@ describe Gitlab::UsageData do
end
end
describe '.requirements_counts' do
subject { described_class.requirements_counts }
context 'when requirements are disabled' do
it 'returns empty hash' do
stub_licensed_features(requirements: false)
expect(subject).to eq({})
end
end
context 'when requirements are enabled' do
it 'returns created requirements count' do
stub_licensed_features(requirements: true)
create_list(:requirement, 2)
expect(subject).to eq({ requirements_created: 2 })
end
end
end
describe '.service_desk_counts' do
subject { described_class.service_desk_counts }
......
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