Commit 6e6da4bb authored by mhasbini's avatar mhasbini

Optimize labels finder query

Optimize labels finder query when searching for a project with a group
parent 37b5b7a5
......@@ -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)
......
---
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