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
end
def filter_labels
if params[:add_label_ids]
params[:add_label_ids] = labels_service.filter_labels_ids_in_param(:add_label_ids)
elsif params[:add_labels]
params[:add_label_ids] = labels_service.find_or_create_by_titles(:add_labels).map(&:id)
label_ids_to_filter(:add_label_ids, :add_labels, false)
label_ids_to_filter(:remove_label_ids, :remove_labels, true)
label_ids_to_filter(:label_ids, :labels, false)
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]
params[:label_ids] = labels_service.filter_labels_ids_in_param(:label_ids)
elsif params[:labels]
params[:label_ids] = labels_service.find_or_create_by_titles.map(&:id)
def label_ids_to_filter(label_id_key, label_key, find_only)
if params[label_id_key]
params[label_id_key] = labels_service.filter_labels_ids_in_param(label_id_key)
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
......
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