Commit 0a42e735 authored by Felipe Artur's avatar Felipe Artur

Add requirements created to usage data

Count created requirements on usage data
parent d5d64b73
...@@ -233,6 +233,7 @@ but commented out to help encourage others to add to it in the future. --> ...@@ -233,6 +233,7 @@ but commented out to help encourage others to add to it in the future. -->
|protected_branches|counts|| |protected_branches|counts||
|releases|counts|| |releases|counts||
|remote_mirrors|counts|| |remote_mirrors|counts||
|requirements_created|counts||
|snippets|counts|| |snippets|counts||
|suggestions|counts|| |suggestions|counts||
|todos|counts|| |todos|counts||
......
...@@ -82,6 +82,14 @@ module EE ...@@ -82,6 +82,14 @@ module EE
usage_data usage_data
end end
def requirements_counts
return {} unless ::License.feature_available?(:requirements)
{
requirements_created: count(RequirementsManagement::Requirement)
}
end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def service_desk_counts def service_desk_counts
return {} unless ::License.feature_available?(:service_desk) return {} unless ::License.feature_available?(:service_desk)
...@@ -160,6 +168,7 @@ module EE ...@@ -160,6 +168,7 @@ module EE
status_page_issues: count(::Issue.on_status_page), status_page_issues: count(::Issue.on_status_page),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates) template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
}, },
requirements_counts,
service_desk_counts, service_desk_counts,
security_products_usage, security_products_usage,
epics_deepest_relationship_level, epics_deepest_relationship_level,
......
...@@ -7,7 +7,7 @@ describe Gitlab::UsageData do ...@@ -7,7 +7,7 @@ describe Gitlab::UsageData do
allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false)
end end
describe '#data' do describe '.data' do
# using Array.new to create a different creator User for each of the projects # 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_it_be(:projects) { Array.new(3) { create(:project, :repository, creator: create(:user, group_view: :security_dashboard)) } }
let(:count_data) { subject[:counts] } let(:count_data) { subject[:counts] }
...@@ -152,7 +152,7 @@ describe Gitlab::UsageData do ...@@ -152,7 +152,7 @@ describe Gitlab::UsageData do
end end
end end
describe '#features_usage_data_ee' do describe '.features_usage_data_ee' do
subject { described_class.features_usage_data_ee } subject { described_class.features_usage_data_ee }
it 'gathers feature usage data of EE' do it 'gathers feature usage data of EE' do
...@@ -162,7 +162,7 @@ describe Gitlab::UsageData do ...@@ -162,7 +162,7 @@ describe Gitlab::UsageData do
end end
end end
describe '#license_usage_data' do describe '.license_usage_data' do
subject { described_class.license_usage_data } subject { described_class.license_usage_data }
it 'gathers license data' do it 'gathers license data' do
...@@ -180,6 +180,28 @@ describe Gitlab::UsageData do ...@@ -180,6 +180,28 @@ describe Gitlab::UsageData do
end end
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 describe '.service_desk_counts' do
subject { described_class.service_desk_counts } 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