Add inverse_of: :pipeline for pipeline.builds (#37987)

This appears to reduce the number of queries in pipeline creation of
gitlab-ce's .gitlab-ci.yml by 92

This also means we now need to mock this ci yaml file properly in the
test because otherwise the yaml_errors stay on the object and make all
the pipelines failed.
This commit is contained in:
Dylan Griffith 2018-02-28 13:56:18 +11:00
parent 59de0443ed
commit e3507c9282
2 changed files with 3 additions and 1 deletions

View file

@ -14,7 +14,7 @@ module Ci
has_many :stages
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
has_many :builds, foreign_key: :commit_id
has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
has_many :variables, class_name: 'Ci::PipelineVariable'

View file

@ -9,6 +9,8 @@ describe Ci::ProcessPipelineService, '#execute' do
end
before do
stub_ci_pipeline_to_return_yaml_file
stub_not_protect_default_branch
project.add_developer(user)