diff options
author | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-10-27 05:52:06 +0300 |
---|---|---|
committer | Heinrich Lee Yu <hleeyu@gmail.com> | 2018-11-01 02:45:36 +0300 |
commit | f5f26f0bf7b2a2fc178e60a472731f8cfa540d75 (patch) | |
tree | 102ecf8b30d7e846299991b4ea330f712534c2e8 /app/finders | |
parent | 31733b6fc5a9ba4443a5dd279e787e2fd8e31c6d (diff) |
Add None / Any options to reaction filter in issues / MRs API
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder.rb | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 92aaa9c6b29..27a850b2603 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -244,15 +244,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) @@ -418,6 +409,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 @@ -480,12 +480,26 @@ 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]) + if filter_by_no_reaction? + items = items.not_awarded(current_user) + elsif filter_by_any_reaction? + items = items.awarded_any(current_user) + else + items = 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] |