Commit f7f9e580 authored by Lin Jen-Shin's avatar Lin Jen-Shin Committed by Clement Ho

Make sure we could query against no one

We should separate the idea of not finding anyone,
and the idea of against no one.
parent 23d43243
...@@ -173,6 +173,10 @@ class IssuableFinder ...@@ -173,6 +173,10 @@ class IssuableFinder
params[:assignee_username].present? && params[:assignee_username] != NONE params[:assignee_username].present? && params[:assignee_username] != NONE
end end
def no_assignee?
params[:assignee_id] == NONE || params[:assignee_username] == NONE
end
def assignee def assignee
return @assignee if defined?(@assignee) return @assignee if defined?(@assignee)
...@@ -194,6 +198,10 @@ class IssuableFinder ...@@ -194,6 +198,10 @@ class IssuableFinder
params[:author_username].present? && params[:author_username] != NONE params[:author_username].present? && params[:author_username] != NONE
end end
def no_author?
params[:author_id] == NONE || params[:author_username] == NONE
end
def author def author
return @author if defined?(@author) return @author if defined?(@author)
...@@ -277,6 +285,8 @@ class IssuableFinder ...@@ -277,6 +285,8 @@ class IssuableFinder
def by_assignee(items) def by_assignee(items)
if assignee if assignee
items = items.where(assignee_id: assignee.id) items = items.where(assignee_id: assignee.id)
elsif no_assignee?
items = items.where(assignee_id: nil)
elsif assignee_id? || assignee_username? # assignee not found elsif assignee_id? || assignee_username? # assignee not found
items = items.none items = items.none
end end
...@@ -287,6 +297,8 @@ class IssuableFinder ...@@ -287,6 +297,8 @@ class IssuableFinder
def by_author(items) def by_author(items)
if author if author
items = items.where(author_id: author.id) items = items.where(author_id: author.id)
elsif no_author?
items = items.where(author_id: nil)
elsif author_id? || author_username? # author not found elsif author_id? || author_username? # author not found
items = items.none items = items.none
end end
......
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