diff --git a/changelogs/unreleased/zj-usage-ping-pool-repository.yml b/changelogs/unreleased/zj-usage-ping-pool-repository.yml new file mode 100644 index 0000000000000000000000000000000000000000..62044a933d038a4847c5ed8acdc6e1a9629ceb83 --- /dev/null +++ b/changelogs/unreleased/zj-usage-ping-pool-repository.yml @@ -0,0 +1,5 @@ +--- +title: Add Pool repository to the usage ping +merge_request: 28267 +author: +type: other diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 08156d7ffa603c34edf3b511fe98d7f09a306104..9aa2e972adf54a4dcde38a500b698392563b7313 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -26,7 +26,7 @@ module Gitlab uuid: Gitlab::CurrentSettings.uuid, hostname: Gitlab.config.gitlab.host, version: Gitlab::VERSION, - installation_type: Gitlab::INSTALLATION_TYPE, + installation_type: installation_type, active_user_count: count(User.active), recorded_at: Time.now, edition: 'CE' @@ -81,6 +81,7 @@ module Gitlab milestone_lists: count(List.milestone), milestones: count(Milestone), pages_domains: count(PagesDomain), + pool_repositories: count(PoolRepository), projects: count(Project), projects_imported_from_github: count(Project.where(import_type: 'github')), projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)), @@ -190,6 +191,14 @@ module Gitlab result[key] = approx_counts[model] || -1 end end + + def installation_type + if Rails.env.production? + Gitlab::INSTALLATION_TYPE + else + "gitlab-development-kit" + end + end end end end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index aa975c8bb0b0e780d95bab567047d1eb30f6ca0a..e44463dd767708e7ca50257eb17b96d1bde16de0 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -63,12 +63,7 @@ describe Gitlab::UsageData do end it "gathers usage counts" do - count_data = subject[:counts] - - expect(count_data[:boards]).to eq(1) - expect(count_data[:projects]).to eq(3) - - expect(count_data.keys).to include(*%i( + expected_keys = %i( assignee_lists boards ci_builds @@ -112,6 +107,7 @@ describe Gitlab::UsageData do milestone_lists milestones notes + pool_repositories projects projects_imported_from_github projects_jira_active @@ -132,7 +128,14 @@ describe Gitlab::UsageData do uploads web_hooks user_preferences - )) + ) + + count_data = subject[:counts] + + expect(count_data[:boards]).to eq(1) + expect(count_data[:projects]).to eq(3) + expect(count_data.keys).to include(*expected_keys) + expect(expected_keys - count_data.keys).to be_empty end it 'does not gather user preferences usage data when the feature is disabled' do @@ -211,7 +214,7 @@ describe Gitlab::UsageData do it "gathers license data" do expect(subject[:uuid]).to eq(Gitlab::CurrentSettings.uuid) expect(subject[:version]).to eq(Gitlab::VERSION) - expect(subject[:installation_type]).to eq(Gitlab::INSTALLATION_TYPE) + expect(subject[:installation_type]).to eq('gitlab-development-kit') expect(subject[:active_user_count]).to eq(User.active.count) expect(subject[:recorded_at]).to be_a(Time) end