summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-01-06 17:32:25 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-01-07 14:53:02 +0100
commit0d0049c0584be2d358048c3cc545406b64bf3826 (patch)
tree2bb931febe9c2a76eedadcfb5d617d9542a55aeb /app/models/issue.rb
parent9dacc3bc568c6c8cfc4a1bc1af23eb96f9eae9b0 (diff)
downloadgitlab-ce-0d0049c0584be2d358048c3cc545406b64bf3826.tar.gz
Don't pluck IDs when getting issues/MRs per group
This replaces plucking of IDs with a sub-query, saving the overhead of loading the data in Ruby and then mapping the rows to an Array of IDs. This also scales much better when dealing with a large amount of IDs that would be involved.
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 80ecd15077f..21cc2105161 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -33,7 +33,7 @@ class Issue < ActiveRecord::Base
belongs_to :project
validates :project, presence: true
- scope :of_group, ->(group) { where(project_id: group.project_ids) }
+ scope :of_group, ->(group) { where(project_id: group.projects.select(:id)) }
scope :cared, ->(user) { where(assignee_id: user) }
scope :open_for, ->(user) { opened.assigned_to(user) }