diff options
-rw-r--r-- | app/controllers/concerns/issues_action.rb | 2 | ||||
-rw-r--r-- | app/controllers/concerns/merge_requests_action.rb | 2 | ||||
-rw-r--r-- | app/finders/issuable_finder.rb | 20 |
3 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb index 91b58c47dd9..5b098628557 100644 --- a/app/controllers/concerns/issues_action.rb +++ b/app/controllers/concerns/issues_action.rb @@ -6,7 +6,7 @@ module IssuesAction @issues = @issues.page(params[:page]).per(ApplicationController::PER_PAGE) @issues = @issues.preload(:author, :project) - @label = Label.where(project: @projects).find_by(title: params[:label_name]) + @label = @issuable_finder.labels.first respond_to do |format| format.html diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb index da30477fb30..f6de696e84d 100644 --- a/app/controllers/concerns/merge_requests_action.rb +++ b/app/controllers/concerns/merge_requests_action.rb @@ -6,6 +6,6 @@ module MergeRequestsAction @merge_requests = @merge_requests.page(params[:page]).per(ApplicationController::PER_PAGE) @merge_requests = @merge_requests.preload(:author, :target_project) - @label = Label.where(project: @projects).find_by(title: params[:label_name]) + @label = @issuable_finder.labels.first end end diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 0a4192e6bac..bc48611f7a6 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -119,6 +119,20 @@ class IssuableFinder labels? && params[:label_name] == Label::None.title end + def labels + return @labels if defined?(@labels) + + if labels? && !filter_by_no_label? + @labels = Label.where(title: label_names) + + if projects + @labels = labels.where(project: projects) + end + else + @labels = Label.none + end + end + def assignee? params[:assignee_id].present? end @@ -253,8 +267,6 @@ class IssuableFinder joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{klass.name}' AND label_links.target_id = #{klass.table_name}.id"). where(label_links: { id: nil }) else - label_names = params[:label_name].split(",") - items = items.joins(:labels).where(labels: { title: label_names }) if projects @@ -266,6 +278,10 @@ class IssuableFinder items end + def label_names + params[:label_name].split(',') + end + def current_user_related? params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me' end |