diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-04-05 13:19:24 +0200 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-04-09 11:58:06 +0100 |
commit | 20fdbbe86a6cffbf467f08d50a0d8ef0f5c87f50 (patch) | |
tree | 771a649785183c6d355483538a69a66824ad320c /app/models/label.rb | |
parent | 63ab7c0f009001b99f6e7d7a7f21dadde1e6b969 (diff) | |
download | gitlab-ce-20fdbbe86a6cffbf467f08d50a0d8ef0f5c87f50.tar.gz |
Use Goldiloader for handling N+1 queries
Goldiloader (https://github.com/salsify/goldiloader) can eager load
associations automatically. This removes the need for adding "includes"
calls in a variety of different places. This also comes with the added
benefit of not having to eager load data if it's not used.
Diffstat (limited to 'app/models/label.rb')
-rw-r--r-- | app/models/label.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/label.rb b/app/models/label.rb index de7f1d56c64..f3496884cff 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -18,8 +18,8 @@ class Label < ActiveRecord::Base has_many :lists, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :priorities, class_name: 'LabelPriority' has_many :label_links, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent - has_many :issues, through: :label_links, source: :target, source_type: 'Issue' - has_many :merge_requests, through: :label_links, source: :target, source_type: 'MergeRequest' + has_many :issues, -> { auto_include(false) }, through: :label_links, source: :target, source_type: 'Issue' + has_many :merge_requests, -> { auto_include(false) }, through: :label_links, source: :target, source_type: 'MergeRequest' before_validation :strip_whitespace_from_title_and_color |