Commit e53f5815 authored by Francisco Javier López's avatar Francisco Javier López Committed by Douglas Barbosa Alexandre

Move SMAU usage counters to the UsageData count field

In other MRs we added some counter as independent params
in the usage data json we use. Nevetheless, they should
be gathered together inside the `count` field in the
`UsageData` model.
parent ae22b486
---
title: Move SMAU usage counters to the UsageData count field
merge_request: 17074
author:
type: fixed
...@@ -55,12 +55,6 @@ describe Gitlab::UsageData do ...@@ -55,12 +55,6 @@ describe Gitlab::UsageData do
)) ))
end end
it do
is_expected.to include(design_management_designs_create: a_kind_of(Integer),
design_management_designs_update: a_kind_of(Integer),
design_management_designs_delete: a_kind_of(Integer))
end
it 'gathers usage counts' do it 'gathers usage counts' do
expect(count_data[:boards]).to eq(1) expect(count_data[:boards]).to eq(1)
expect(count_data[:projects]).to eq(3) expect(count_data[:projects]).to eq(3)
...@@ -87,6 +81,9 @@ describe Gitlab::UsageData do ...@@ -87,6 +81,9 @@ describe Gitlab::UsageData do
projects_with_prometheus_alerts projects_with_prometheus_alerts
projects_with_tracing_enabled projects_with_tracing_enabled
sast_jobs sast_jobs
design_management_designs_create
design_management_designs_update
design_management_designs_delete
)) ))
expect(count_data[:projects_with_prometheus_alerts]).to eq(2) expect(count_data[:projects_with_prometheus_alerts]).to eq(2)
......
...@@ -17,7 +17,6 @@ module Gitlab ...@@ -17,7 +17,6 @@ module Gitlab
.merge(features_usage_data) .merge(features_usage_data)
.merge(components_usage_data) .merge(components_usage_data)
.merge(cycle_analytics_usage_data) .merge(cycle_analytics_usage_data)
.merge(usage_counters)
end end
def to_json(force_refresh: false) def to_json(force_refresh: false)
...@@ -99,6 +98,7 @@ module Gitlab ...@@ -99,6 +98,7 @@ module Gitlab
web_hooks: count(WebHook) web_hooks: count(WebHook)
}.merge(services_usage) }.merge(services_usage)
.merge(approximate_counts) .merge(approximate_counts)
.merge(usage_counters)
}.tap do |data| }.tap do |data|
data[:counts][:user_preferences] = user_preferences_usage data[:counts][:user_preferences] = user_preferences_usage
end end
......
...@@ -64,31 +64,29 @@ describe Gitlab::UsageData do ...@@ -64,31 +64,29 @@ describe Gitlab::UsageData do
avg_cycle_analytics avg_cycle_analytics
influxdb_metrics_enabled influxdb_metrics_enabled
prometheus_metrics_enabled prometheus_metrics_enabled
cycle_analytics_views
productivity_analytics_views
)) ))
expect(subject).to include(
snippet_create: a_kind_of(Integer),
snippet_update: a_kind_of(Integer),
snippet_comment: a_kind_of(Integer),
merge_request_comment: a_kind_of(Integer),
merge_request_create: a_kind_of(Integer),
commit_comment: a_kind_of(Integer),
wiki_pages_create: a_kind_of(Integer),
wiki_pages_update: a_kind_of(Integer),
wiki_pages_delete: a_kind_of(Integer),
web_ide_views: a_kind_of(Integer),
web_ide_commits: a_kind_of(Integer),
web_ide_merge_requests: a_kind_of(Integer),
navbar_searches: a_kind_of(Integer),
cycle_analytics_views: a_kind_of(Integer),
productivity_analytics_views: a_kind_of(Integer),
source_code_pushes: a_kind_of(Integer)
)
end end
it 'gathers usage counts' do it 'gathers usage counts' do
smau_keys = %i(
snippet_create
snippet_update
snippet_comment
merge_request_comment
merge_request_create
commit_comment
wiki_pages_create
wiki_pages_update
wiki_pages_delete
web_ide_views
web_ide_commits
web_ide_merge_requests
navbar_searches
cycle_analytics_views
productivity_analytics_views
source_code_pushes
)
expected_keys = %i( expected_keys = %i(
assignee_lists assignee_lists
boards boards
...@@ -154,12 +152,13 @@ describe Gitlab::UsageData do ...@@ -154,12 +152,13 @@ describe Gitlab::UsageData do
uploads uploads
web_hooks web_hooks
user_preferences user_preferences
) ).push(*smau_keys)
count_data = subject[:counts] count_data = subject[:counts]
expect(count_data[:boards]).to eq(1) expect(count_data[:boards]).to eq(1)
expect(count_data[:projects]).to eq(4) expect(count_data[:projects]).to eq(4)
expect(count_data.values_at(*smau_keys)).to all(be_an(Integer))
expect(count_data.keys).to include(*expected_keys) expect(count_data.keys).to include(*expected_keys)
expect(expected_keys - count_data.keys).to be_empty expect(expected_keys - count_data.keys).to be_empty
end end
......
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