Commit 86e2b07a authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'labels-finder-optimize-project' into 'master'

Optimize labels finder query

See merge request !10248
parents 7324d671 6e6da4bb
...@@ -20,8 +20,17 @@ class LabelsFinder < UnionFinder ...@@ -20,8 +20,17 @@ class LabelsFinder < UnionFinder
if project? if project?
if project if project
label_ids << project.group.labels if project.group.present? if project.group.present?
label_ids << project.labels 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 end
else else
label_ids << Label.where(group_id: projects.group_ids) label_ids << Label.where(group_id: projects.group_ids)
......
---
title: Optimize labels finder query when searching for a project with a group
merge_request:
author: mhasbini
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment