From aa1b7f2dc4c8995e20deba0e0e9ed60cf04fb1f7 Mon Sep 17 00:00:00 2001 From: Dylan Griffith Date: Wed, 21 Feb 2018 15:34:38 +1100 Subject: [PATCH] Add inverse_of pipeline -> statuses -> pipeline (#43134) --- app/models/ci/pipeline.rb | 2 +- .../43134-reduce-queries-pipelines-controller-show.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/43134-reduce-queries-pipelines-controller-show.yml diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 2abe90dd181..a72a815bfe8 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -13,7 +13,7 @@ module Ci belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule' has_many :stages - has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id + has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :builds, foreign_key: :commit_id has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent has_many :variables, class_name: 'Ci::PipelineVariable' diff --git a/changelogs/unreleased/43134-reduce-queries-pipelines-controller-show.yml b/changelogs/unreleased/43134-reduce-queries-pipelines-controller-show.yml new file mode 100644 index 00000000000..c1e9614b676 --- /dev/null +++ b/changelogs/unreleased/43134-reduce-queries-pipelines-controller-show.yml @@ -0,0 +1,5 @@ +--- +title: Improve performance of pipeline page by reducing DB queries +merge_request: 17168 +author: +type: performance