diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-19 19:56:27 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-27 12:47:44 +0200 |
commit | 4447006832d8955f371e2430988e0c95b20f155d (patch) | |
tree | 0d82fa7332f47bc79b647c77161f3c02237f93f4 | |
parent | 9c7bf123564ee3c045c2aa3625f8a691f91a23aa (diff) | |
download | gitlab-ce-4447006832d8955f371e2430988e0c95b20f155d.tar.gz |
Split pipelines by origin on usage datazj-usage-ping-only-gl-pipelines
When sending the usage data, it now includes all pipelines. This commit
will split the pipelines in two; internal and external.
This will lead to historical data being incorrectly marked this way.
Fixes gitlab-org/gitlab-ce#33172
-rw-r--r-- | app/models/ci/pipeline.rb | 5 | ||||
-rw-r--r-- | changelogs/unreleased/zj-usage-ping-only-gl-pipelines.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/usage_data.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 6 |
5 files changed, 19 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 1b3e5a25ac2..364858964b0 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -140,6 +140,7 @@ module Ci where(id: max_id) end end + scope :internal, -> { where(source: internal_sources) } def self.latest_status(ref = nil) latest(ref).status @@ -163,6 +164,10 @@ module Ci where.not(duration: nil).sum(:duration) end + def self.internal_sources + sources.reject { |source| source == "external" }.values + end + def stages_count statuses.select(:stage).distinct.count end diff --git a/changelogs/unreleased/zj-usage-ping-only-gl-pipelines.yml b/changelogs/unreleased/zj-usage-ping-only-gl-pipelines.yml new file mode 100644 index 00000000000..0ace7b99657 --- /dev/null +++ b/changelogs/unreleased/zj-usage-ping-only-gl-pipelines.yml @@ -0,0 +1,4 @@ +--- +title: Split pipelines as internal and external in the usage data +merge_request: 12277 +author: diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index bcba2e3e1b6..b23a2934874 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -20,7 +20,8 @@ module Gitlab counts: { boards: Board.count, ci_builds: ::Ci::Build.count, - ci_pipelines: ::Ci::Pipeline.count, + ci_internal_pipelines: ::Ci::Pipeline.internal.count, + ci_external_pipelines: ::Ci::Pipeline.external.count, ci_runners: ::Ci::Runner.count, ci_triggers: ::Ci::Trigger.count, ci_pipeline_schedules: ::Ci::PipelineSchedule.count, diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index b47e1b56fa9..9196d0ccc3f 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -30,7 +30,8 @@ describe Gitlab::UsageData do expect(count_data.keys).to match_array(%i( boards ci_builds - ci_pipelines + ci_internal_pipelines + ci_external_pipelines ci_runners ci_triggers ci_pipeline_schedules diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index dab8e8ca432..55d85a6e228 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -672,6 +672,12 @@ describe Ci::Pipeline, models: true do end end + describe '.internal_sources' do + subject { described_class.internal_sources } + + it { is_expected.to be_an(Array) } + end + describe '#status' do let(:build) do create(:ci_build, :created, pipeline: pipeline, name: 'test') |