Read about our upcoming Code of Conduct on this issue

Commit dfb4fcb6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

No magic numbers for issues filtering

parent 9e55545cd9fc
......@@ -19,6 +19,8 @@
require_relative 'projects_finder'
class IssuableFinder
NONE = 0
attr_accessor :current_user, :params
def execute(current_user, params)
......@@ -112,7 +114,7 @@ def sort(items)
def by_milestone(items)
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
items
......@@ -120,7 +122,7 @@ def by_milestone(items)
def by_assignee(items)
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
items
......@@ -128,7 +130,7 @@ def by_assignee(items)
def by_author(items)
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
items
......
......@@ -14,8 +14,8 @@ def execute(issue)
issue.update_nth_task(params[:task_num].to_i, false)
end
params[:assignee_id] = "" if params[:assignee_id] == "-1"
params[:milestone_id] = "" if params[:milestone_id] == "-1"
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
old_labels = issue.labels.to_a
......
......@@ -23,8 +23,8 @@ def execute(merge_request)
merge_request.update_nth_task(params[:task_num].to_i, false)
end
params[:assignee_id] = "" if params[:assignee_id] == "-1"
params[:milestone_id] = "" if params[:milestone_id] == "-1"
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
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