Commit dfb4fcb6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

No magic numbers for issues filtering

parent 090f2344
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
require_relative 'projects_finder' require_relative 'projects_finder'
class IssuableFinder class IssuableFinder
NONE = 0
attr_accessor :current_user, :params attr_accessor :current_user, :params
def execute(current_user, params) def execute(current_user, params)
...@@ -112,7 +114,7 @@ class IssuableFinder ...@@ -112,7 +114,7 @@ class IssuableFinder
def by_milestone(items) def by_milestone(items)
if params[:milestone_id].present? if params[:milestone_id].present?
items = items.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) items = items.where(milestone_id: (params[:milestone_id] == NONE ? nil : params[:milestone_id]))
end end
items items
...@@ -120,7 +122,7 @@ class IssuableFinder ...@@ -120,7 +122,7 @@ class IssuableFinder
def by_assignee(items) def by_assignee(items)
if params[:assignee_id].present? if params[:assignee_id].present?
items = items.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) items = items.where(assignee_id: (params[:assignee_id] == NONE ? nil : params[:assignee_id]))
end end
items items
...@@ -128,7 +130,7 @@ class IssuableFinder ...@@ -128,7 +130,7 @@ class IssuableFinder
def by_author(items) def by_author(items)
if params[:author_id].present? if params[:author_id].present?
items = items.where(author_id: (params[:author_id] == '0' ? nil : params[:author_id])) items = items.where(author_id: (params[:author_id] == NONE ? nil : params[:author_id]))
end end
items items
......
...@@ -14,8 +14,8 @@ module Issues ...@@ -14,8 +14,8 @@ module Issues
issue.update_nth_task(params[:task_num].to_i, false) issue.update_nth_task(params[:task_num].to_i, false)
end end
params[:assignee_id] = "" if params[:assignee_id] == "-1" params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == "-1" params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
old_labels = issue.labels.to_a old_labels = issue.labels.to_a
......
...@@ -23,8 +23,8 @@ module MergeRequests ...@@ -23,8 +23,8 @@ module MergeRequests
merge_request.update_nth_task(params[:task_num].to_i, false) merge_request.update_nth_task(params[:task_num].to_i, false)
end end
params[:assignee_id] = "" if params[:assignee_id] == "-1" params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == "-1" params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
old_labels = merge_request.labels.to_a old_labels = merge_request.labels.to_a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment