Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/finders/todos_finder.rb
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/finders/todos_finder.rb')
-rw-r--r--app/finders/todos_finder.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 672bbd52b07..a2054f73c9d 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -11,7 +11,7 @@
# author_id: integer
# project_id; integer
# state: 'pending' (default) or 'done'
-# type: 'Issue' or 'MergeRequest'
+# type: 'Issue' or 'MergeRequest' or ['Issue', 'MergeRequest']
#
class TodosFinder
@@ -40,13 +40,14 @@ class TodosFinder
def execute
return Todo.none if current_user.nil?
+ raise ArgumentError, invalid_type_message unless valid_types?
items = current_user.todos
items = by_action_id(items)
items = by_action(items)
items = by_author(items)
items = by_state(items)
- items = by_type(items)
+ items = by_types(items)
items = by_group(items)
# Filtering by project HAS TO be the last because we use
# the project IDs yielded by the todos query thus far
@@ -123,12 +124,16 @@ class TodosFinder
end
end
- def type?
- type.present? && self.class.todo_types.include?(type)
+ def types
+ @types ||= Array(params[:type]).reject(&:blank?)
end
- def type
- params[:type]
+ def valid_types?
+ types.all? { |type| self.class.todo_types.include?(type) }
+ end
+
+ def invalid_type_message
+ _("Unsupported todo type passed. Supported todo types are: %{todo_types}") % { todo_types: self.class.todo_types.to_a.join(', ') }
end
def sort(items)
@@ -193,9 +198,9 @@ class TodosFinder
items.with_states(params[:state])
end
- def by_type(items)
- if type?
- items.for_type(type)
+ def by_types(items)
+ if types.any?
+ items.for_type(types)
else
items
end