Split pipelines by origin on usage data
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
This commit is contained in:
parent
9c7bf12356
commit
4447006832
|
@ -140,6 +140,7 @@ module Ci
|
||||||
where(id: max_id)
|
where(id: max_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
scope :internal, -> { where(source: internal_sources) }
|
||||||
|
|
||||||
def self.latest_status(ref = nil)
|
def self.latest_status(ref = nil)
|
||||||
latest(ref).status
|
latest(ref).status
|
||||||
|
@ -163,6 +164,10 @@ module Ci
|
||||||
where.not(duration: nil).sum(:duration)
|
where.not(duration: nil).sum(:duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.internal_sources
|
||||||
|
sources.reject { |source| source == "external" }.values
|
||||||
|
end
|
||||||
|
|
||||||
def stages_count
|
def stages_count
|
||||||
statuses.select(:stage).distinct.count
|
statuses.select(:stage).distinct.count
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Split pipelines as internal and external in the usage data
|
||||||
|
merge_request: 12277
|
||||||
|
author:
|
|
@ -20,7 +20,8 @@ module Gitlab
|
||||||
counts: {
|
counts: {
|
||||||
boards: Board.count,
|
boards: Board.count,
|
||||||
ci_builds: ::Ci::Build.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_runners: ::Ci::Runner.count,
|
||||||
ci_triggers: ::Ci::Trigger.count,
|
ci_triggers: ::Ci::Trigger.count,
|
||||||
ci_pipeline_schedules: ::Ci::PipelineSchedule.count,
|
ci_pipeline_schedules: ::Ci::PipelineSchedule.count,
|
||||||
|
|
|
@ -30,7 +30,8 @@ describe Gitlab::UsageData do
|
||||||
expect(count_data.keys).to match_array(%i(
|
expect(count_data.keys).to match_array(%i(
|
||||||
boards
|
boards
|
||||||
ci_builds
|
ci_builds
|
||||||
ci_pipelines
|
ci_internal_pipelines
|
||||||
|
ci_external_pipelines
|
||||||
ci_runners
|
ci_runners
|
||||||
ci_triggers
|
ci_triggers
|
||||||
ci_pipeline_schedules
|
ci_pipeline_schedules
|
||||||
|
|
|
@ -672,6 +672,12 @@ describe Ci::Pipeline, models: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.internal_sources' do
|
||||||
|
subject { described_class.internal_sources }
|
||||||
|
|
||||||
|
it { is_expected.to be_an(Array) }
|
||||||
|
end
|
||||||
|
|
||||||
describe '#status' do
|
describe '#status' do
|
||||||
let(:build) do
|
let(:build) do
|
||||||
create(:ci_build, :created, pipeline: pipeline, name: 'test')
|
create(:ci_build, :created, pipeline: pipeline, name: 'test')
|
||||||
|
|
Loading…
Reference in New Issue