Commit 66b97bc2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Abstract persisted/legacy stages in pipeline model

Conflicts:
	app/controllers/projects/pipelines_controller.rb
parent 9d1b37c3
...@@ -262,6 +262,16 @@ module Ci ...@@ -262,6 +262,16 @@ module Ci
stage unless stage.statuses_count.zero? stage unless stage.statuses_count.zero?
end end
##
# TODO consider switching to persisted stages only in pipelines table
# (not necessairly in the show pipeline page because of #23257.
# Hide this behind two feature flags - enabled / disabled and only
# gitlab-ce / everywhere.
#
def stages
super
end
def legacy_stages def legacy_stages
# TODO, this needs refactoring, see gitlab-ce#26481. # TODO, this needs refactoring, see gitlab-ce#26481.
......
class PipelineDetailsEntity < PipelineEntity class PipelineDetailsEntity < PipelineEntity
expose :details do expose :details do
## expose :stages, using: StageEntity
# TODO consider switching to persisted stages only in pipelines table
# (not necessairly in the show pipeline page because of #23257.
# Hide this behind two feature flags - enabled / disabled and only
# gitlab-ce / everywhere.
expose :stages, as: :stages, using: StageEntity
expose :artifacts, using: BuildArtifactEntity expose :artifacts, using: BuildArtifactEntity
expose :manual_actions, using: BuildActionEntity expose :manual_actions, using: BuildActionEntity
end end
......
...@@ -17,8 +17,7 @@ describe Projects::PipelinesController do ...@@ -17,8 +17,7 @@ describe Projects::PipelinesController do
describe 'GET index.json' do describe 'GET index.json' do
before do before do
%w(pending running running success canceled) %w(pending running success failed).each_with_index do |status, index|
.each_with_index do |status, index|
create_pipeline(status, project.commit("HEAD~#{index}")) create_pipeline(status, project.commit("HEAD~#{index}"))
end end
end end
...@@ -32,11 +31,13 @@ describe Projects::PipelinesController do ...@@ -32,11 +31,13 @@ describe Projects::PipelinesController do
expect(response).to match_response_schema('pipeline') expect(response).to match_response_schema('pipeline')
expect(json_response).to include('pipelines') expect(json_response).to include('pipelines')
expect(json_response['pipelines'].count).to eq 5 expect(json_response['pipelines'].count).to eq 4
expect(json_response['count']['all']).to eq '5' expect(json_response['count']['all']).to eq '4'
expect(json_response['count']['running']).to eq '2' expect(json_response['count']['running']).to eq '1'
expect(json_response['count']['pending']).to eq '1' expect(json_response['count']['pending']).to eq '1'
expect(json_response['count']['finished']).to eq '2' expect(json_response['count']['finished']).to eq '2'
puts queries.log
puts "Queries count: #{queries.count}"
expect(queries.count).to be < 32 expect(queries.count).to be < 32
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