diff options
author | Sean McGivern <sean@gitlab.com> | 2018-11-01 14:07:09 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-11-01 14:07:09 +0300 |
commit | c49f57fe430edeac9a5f2423dac7afb80ff72576 (patch) | |
tree | 23c8e45711083748f18d81a9f40f3b464e4b62cb /app/finders | |
parent | f7c0a18b8a061bfea650897b22dce24d712c6439 (diff) | |
parent | 8df7e6021b0da30e3b7550ca83cd9ab3f991c235 (diff) |
Merge branch 'engwan/gitlab-ce-44012-filter-reactions-none-any'
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder.rb | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 419f55fe324..93bef592c65 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -240,15 +240,6 @@ class IssuableFinder params[:assignee_username].present? end - def filter_by_no_assignee? - # Assignee_id takes precedence over assignee_username - [NONE, FILTER_NONE].include?(params[:assignee_id].to_s.downcase) || params[:assignee_username].to_s == NONE - end - - def filter_by_any_assignee? - params[:assignee_id].to_s.downcase == FILTER_ANY - end - # rubocop: disable CodeReuse/ActiveRecord def assignee return @assignee if defined?(@assignee) @@ -414,6 +405,15 @@ class IssuableFinder end # rubocop: enable CodeReuse/ActiveRecord + def filter_by_no_assignee? + # Assignee_id takes precedence over assignee_username + [NONE, FILTER_NONE].include?(params[:assignee_id].to_s.downcase) || params[:assignee_username].to_s == NONE + end + + def filter_by_any_assignee? + params[:assignee_id].to_s.downcase == FILTER_ANY + end + # rubocop: disable CodeReuse/ActiveRecord def by_author(items) if author @@ -482,12 +482,27 @@ class IssuableFinder def by_my_reaction_emoji(items) if params[:my_reaction_emoji].present? && current_user - items = items.awarded(current_user, params[:my_reaction_emoji]) + items = + if filter_by_no_reaction? + items.not_awarded(current_user) + elsif filter_by_any_reaction? + items.awarded(current_user) + else + items.awarded(current_user, params[:my_reaction_emoji]) + end end items end + def filter_by_no_reaction? + params[:my_reaction_emoji].to_s.downcase == FILTER_NONE + end + + def filter_by_any_reaction? + params[:my_reaction_emoji].to_s.downcase == FILTER_ANY + end + def label_names if labels? params[:label_name].is_a?(String) ? params[:label_name].split(',') : params[:label_name] |