diff options
author | Darby Frey <dfrey@gitlab.com> | 2019-02-07 12:35:12 -0600 |
---|---|---|
committer | Darby Frey <dfrey@gitlab.com> | 2019-02-07 12:35:12 -0600 |
commit | b26fb6fde503a4704df1677349b62de1db4cb3c6 (patch) | |
tree | cc236e5ea52e9ed14b8a7351268517e3e4819a7e | |
parent | 232ae06a829ba1a7e795564f711e730bd839be41 (diff) | |
download | gitlab-ce-b26fb6fde503a4704df1677349b62de1db4cb3c6.tar.gz |
Adding additional usage metrics for Release to weekly ping
-rw-r--r-- | lib/gitlab/usage_data.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 26 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 6bfcf83f388..37c29a0cb3f 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -54,6 +54,8 @@ module Gitlab auto_devops_disabled: count(::ProjectAutoDevops.disabled), deploy_keys: count(DeployKey), deployments: count(Deployment), + successful_deployments: count(Deployment.success), + failed_deployments: count(Deployment.failed), environments: count(::Environment), clusters: count(::Clusters::Cluster), clusters_enabled: count(::Clusters::Cluster.enabled), @@ -79,6 +81,7 @@ module Gitlab milestone_lists: count(List.milestone), milestones: count(Milestone), pages_domains: count(PagesDomain), + deployed_pages_projects: count(::Ci::Build.select(:project_id).distinct.where(name: 'pages:deploy')), 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)), diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 4f5993ba226..715ee4afb28 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -79,6 +79,8 @@ describe Gitlab::UsageData do auto_devops_disabled deploy_keys deployments + successful_deployments + failed_deployments environments clusters clusters_enabled @@ -116,6 +118,7 @@ describe Gitlab::UsageData do projects_prometheus_active projects_with_repositories_enabled pages_domains + deployed_pages_projects protected_branches releases remote_mirrors @@ -243,4 +246,27 @@ describe Gitlab::UsageData do expect(described_class.approximate_counts.values.uniq).to eq([-1]) end end + + describe '#deployed_pages_projects' do + let(:pipeline1){ create(:ci_pipeline) } + let(:pipeline2){ create(:ci_pipeline) } + + it 'excludes builds that are not of name pages:deploy' do + create(:ci_build, name: 'pages:deploy', pipeline: pipeline1) + create(:ci_build, name: 'pages:deploy', pipeline: pipeline1) + create(:ci_build, name: 'foo', pipeline: pipeline2) + count_data = described_class.data[:counts] + + expect(count_data[:deployed_pages_projects]).to be(1) + end + + it 'returns the distinct count when multiple builds exist for the same project' do + create(:ci_build, name: 'pages:deploy', pipeline: pipeline1) + create(:ci_build, name: 'pages:deploy', pipeline: pipeline1) + create(:ci_build, name: 'pages:deploy', pipeline: pipeline2) + count_data = described_class.data[:counts] + + expect(count_data[:deployed_pages_projects]).to be(2) + end + end end |