Make sure we could query against no one
We should separate the idea of not finding anyone, and the idea of against no one.
This commit is contained in:
parent
23d43243a1
commit
f7f9e58092
|
@ -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
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue