summaryrefslogtreecommitdiff
path: root/app/finders/todos_finder.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-06-22 19:15:09 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2016-07-01 14:52:04 +0200
commit3942621329b20307c1676d60324c8f47ea1e1b37 (patch)
tree45ec7ce2810878a7951946754cad10fad28642ab /app/finders/todos_finder.rb
parentfd9cd5ae8cd2d2f5488635b264eb86d89d768d66 (diff)
downloadgitlab-ce-3942621329b20307c1676d60324c8f47ea1e1b37.tar.gz
Expose target, filter by state as string
Diffstat (limited to 'app/finders/todos_finder.rb')
-rw-r--r--app/finders/todos_finder.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 58a00f88af7..7806d9e4cc5 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -25,6 +25,7 @@ class TodosFinder
def execute
items = current_user.todos
items = by_action_id(items)
+ items = by_action(items)
items = by_author(items)
items = by_project(items)
items = by_state(items)
@@ -43,6 +44,18 @@ class TodosFinder
params[:action_id]
end
+ def to_action_id
+ Todo::ACTION_NAMES.key(action.to_sym)
+ end
+
+ def action?
+ action.present? && to_action_id
+ end
+
+ def action
+ params[:action]
+ end
+
def author?
params[:author_id].present?
end
@@ -96,6 +109,14 @@ class TodosFinder
params[:type]
end
+ def by_action(items)
+ if action?
+ items = items.where(action: to_action_id)
+ end
+
+ items
+ end
+
def by_action_id(items)
if action_id?
items = items.where(action: action_id)