Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-01-14 10:18:50 +0300
committerStan Hu <stanhu@gmail.com>2018-01-14 19:11:51 +0300
commit8ddb00adbf73ede641bfa93388e18591c03e6668 (patch)
tree2520430147eb7514e6c373e095763a42fe5079ab /app/models/ci/pipeline.rb
parent74f2f9b30fb1972a26481072486b358eb943309f (diff)
Ensure CI pipelines and builds have the correction project associations
This should reduce the number of SQL queries and lookups needed to look up a project of a build and pipeline and vice versa. Before: ``` [1] pry(main)> Ci::Build.reflect_on_association(:project).has_inverse? => false [2] pry(main)> Project.reflect_on_association(:builds).has_inverse? => false [3] pry(main)> Ci::Pipeline.reflect_on_association(:project).has_inverse? => false [4] pry(main)> Project.reflect_on_association(:pipelines).has_inverse? => :project ``` After: ``` [1] pry(main)> Ci::Build.reflect_on_association(:project).has_inverse? => :builds [2] pry(main)> Project.reflect_on_association(:builds).has_inverse? => :project [3] pry(main)> Ci::Pipeline.reflect_on_association(:project).has_inverse? => :pipelines [4] pry(main)> Project.reflect_on_association(:pipelines).has_inverse? => :project ```
Diffstat (limited to 'app/models/ci/pipeline.rb')
-rw-r--r--app/models/ci/pipeline.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index d4690da3be6..d7153d7b816 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -7,7 +7,7 @@ module Ci
include Presentable
include Gitlab::OptimisticLocking
- belongs_to :project
+ belongs_to :project, inverse_of: :pipelines
belongs_to :user
belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule'