diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 14:26:23 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 14:26:23 +0400 |
commit | 4c6859a2dee6da420f33c3b7f9946f3642eb85f7 (patch) | |
tree | 1c62fed89f5b46b95677a18c6326b433f4da3832 | |
parent | 048a21974ef56285099eb4b54b6ca1e6fd7e3e8c (diff) |
Prevent duplicates in issue finder when filter by label
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/finders/base_finder.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/finders/base_finder.rb b/app/finders/base_finder.rb index ad63135e7e6..ec5f5919d7e 100644 --- a/app/finders/base_finder.rb +++ b/app/finders/base_finder.rb @@ -125,7 +125,13 @@ class BaseFinder def by_label(items) if params[:label_name].present? - items = items.joins(:labels).where("labels.title in (?)", params[:label_name].split(",")) + label_names = params[:label_name].split(",") + + item_ids = LabelLink.joins(:label). + where('labels.title in (?)', label_names). + where(target_type: klass.name).pluck(:target_id) + + items = items.where(id: item_ids) end items |