Fix filtering issues by "No Label"

parent 5490a9fe
...@@ -3,7 +3,8 @@ module Boards ...@@ -3,7 +3,8 @@ module Boards
class ListService < Boards::BaseService class ListService < Boards::BaseService
def execute def execute
issues = IssuesFinder.new(user, filter_params).execute issues = IssuesFinder.new(user, filter_params).execute
issues = without_board_labels(issues) if list.backlog? issues = without_board_labels(issues) unless list.label?
issues = with_list_label(issues) if list.label?
issues issues
end end
...@@ -16,7 +17,6 @@ module Boards ...@@ -16,7 +17,6 @@ module Boards
def filter_params def filter_params
set_default_scope set_default_scope
set_default_sort set_default_sort
set_list_label
set_project set_project
set_state set_state
...@@ -31,13 +31,6 @@ module Boards ...@@ -31,13 +31,6 @@ module Boards
params[:sort] = 'priority' params[:sort] = 'priority'
end end
def set_list_label
return unless list.label?
params[:label_name] ||= []
params[:label_name] << list.label_name
end
def set_project def set_project
params[:project_id] = project.id params[:project_id] = project.id
end end
...@@ -58,6 +51,13 @@ module Boards ...@@ -58,6 +51,13 @@ module Boards
.where(label_id: board_label_ids).limit(1).arel.exists .where(label_id: board_label_ids).limit(1).arel.exists
) )
end end
def with_list_label(issues)
issues.where(
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1).arel.exists
)
end
end end
end end
end end
...@@ -39,7 +39,7 @@ describe Boards::Issues::ListService, services: true do ...@@ -39,7 +39,7 @@ describe Boards::Issues::ListService, services: true do
it 'delegates search to IssuesFinder' do it 'delegates search to IssuesFinder' do
params = { id: list1.id } params = { id: list1.id }
expect_any_instance_of(IssuesFinder).to receive(:execute).once expect_any_instance_of(IssuesFinder).to receive(:execute).once.and_call_original
described_class.new(project, user, params).execute described_class.new(project, user, params).execute
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