Commit 582e075e authored by Christian Couder's avatar Christian Couder

Simplify filter_labels method in IssuableBaseService

IssuableBaseService::filter_labels() has been refactored to call
a new `label_ids_to_filter` method.
parent 760d4a16
...@@ -76,22 +76,16 @@ class IssuableBaseService < BaseService ...@@ -76,22 +76,16 @@ class IssuableBaseService < BaseService
end end
def filter_labels def filter_labels
if params[:add_label_ids] label_ids_to_filter(:add_label_ids, :add_labels, false)
params[:add_label_ids] = labels_service.filter_labels_ids_in_param(:add_label_ids) label_ids_to_filter(:remove_label_ids, :remove_labels, true)
elsif params[:add_labels] label_ids_to_filter(:label_ids, :labels, false)
params[:add_label_ids] = labels_service.find_or_create_by_titles(:add_labels).map(&:id) end
end
if params[:remove_label_ids]
params[:remove_label_ids] = labels_service.filter_labels_ids_in_param(:remove_label_ids)
elsif params[:remove_labels]
params[:remove_label_ids] = labels_service.find_or_create_by_titles(:remove_labels, find_only: true).map(&:id)
end
if params[:label_ids] def label_ids_to_filter(label_id_key, label_key, find_only)
params[:label_ids] = labels_service.filter_labels_ids_in_param(:label_ids) if params[label_id_key]
elsif params[:labels] params[label_id_key] = labels_service.filter_labels_ids_in_param(label_id_key)
params[:label_ids] = labels_service.find_or_create_by_titles.map(&:id) elsif params[label_key]
params[label_id_key] = labels_service.find_or_create_by_titles(label_key, find_only: find_only).map(&:id)
end end
end end
......
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