summaryrefslogtreecommitdiff
path: root/app/models/ci/runner.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-02-26 11:30:43 -0800
committerStan Hu <stanhu@gmail.com>2019-02-26 12:44:28 -0800
commitebb284c0dc59e2fd5bc76921609b60034f000c53 (patch)
treea80846427413ae82868fc391ecda6edab846eb28 /app/models/ci/runner.rb
parent3395eacb57285424b7b8d49bdf836f638af31e8c (diff)
downloadgitlab-ce-ebb284c0dc59e2fd5bc76921609b60034f000c53.tar.gz
Remove N+1 query for tags in /admin/runners page
As discussed in https://github.com/mbleigh/acts-as-taggable-on/issues/91, we can avoid N+1 queries if we use `tags` instead of `tag_list`. Seen while reviewing https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19740.
Diffstat (limited to 'app/models/ci/runner.rb')
-rw-r--r--app/models/ci/runner.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 5aae31de6e2..d82e11bbb89 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -97,6 +97,7 @@ module Ci
scope :order_contacted_at_asc, -> { order(contacted_at: :asc) }
scope :order_created_at_desc, -> { order(created_at: :desc) }
+ scope :with_tags, -> { preload(:tags) }
validate :tag_constraints
validates :access_level, presence: true