summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-03-27 10:46:56 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-03-27 10:46:56 +0000
commit86e2b07ab247655758b6927c27743782c77d93e0 (patch)
tree250b72b22cfc374f94662ca2b2423249bfe9556a /app
parent7324d6713262d7f9c563d48b82934c4a8eb72a52 (diff)
parent6e6da4bbcc1dd8f2255d154423bee3a0f63847bc (diff)
downloadgitlab-ce-86e2b07ab247655758b6927c27743782c77d93e0.tar.gz
Merge branch 'labels-finder-optimize-project' into 'master'
Optimize labels finder query See merge request !10248
Diffstat (limited to 'app')
-rw-r--r--app/finders/labels_finder.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index fa0e2a5e3d8..e52083f86e4 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -20,8 +20,17 @@ class LabelsFinder < UnionFinder
if project?
if project
- label_ids << project.group.labels if project.group.present?
- label_ids << project.labels
+ if project.group.present?
+ labels_table = Label.arel_table
+
+ label_ids << Label.where(
+ labels_table[:type].eq('GroupLabel').and(labels_table[:group_id].eq(project.group.id)).or(
+ labels_table[:type].eq('ProjectLabel').and(labels_table[:project_id].eq(project.id))
+ )
+ )
+ else
+ label_ids << project.labels
+ end
end
else
label_ids << Label.where(group_id: projects.group_ids)