summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2016-11-07 16:33:51 -0600
committerClement Ho <ClemMakesApps@gmail.com>2017-01-09 16:00:49 -0600
commitd0165c82877cbc0ddd939713e7365337e0e5478f (patch)
tree3b0a963171fc12a5fed36de161a8b8b1eeb371ad /app/finders
parentfc6eab6919e5cc2426328061df22e9c8985f201b (diff)
downloadgitlab-ce-d0165c82877cbc0ddd939713e7365337e0e5478f.tar.gz
Add author_username and assignee_username
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/issuable_finder.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index b4c14d05eaf..2afde8ece65 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -165,31 +165,43 @@ class IssuableFinder
end
end
- def assignee?
+ def assignee_id?
params[:assignee_id].present?
end
+ def assignee_username?
+ params[:assignee_username].present?
+ end
+
def assignee
return @assignee if defined?(@assignee)
@assignee =
- if assignee? && params[:assignee_id] != NONE
+ if assignee_id? && params[:assignee_id] != NONE
User.find(params[:assignee_id])
+ elsif assignee_username? && params[:assignee_username] != NONE
+ User.find_by(username: params[:assignee_username])
else
nil
end
end
- def author?
+ def author_id?
params[:author_id].present?
end
+ def author_username?
+ params[:author_username].present?
+ end
+
def author
return @author if defined?(@author)
@author =
- if author? && params[:author_id] != NONE
+ if author_id? && params[:author_id] != NONE
User.find(params[:author_id])
+ elsif author_username? && params[:author_username] != NONE
+ User.find_by(username: params[:author_username])
else
nil
end
@@ -263,7 +275,7 @@ class IssuableFinder
end
def by_assignee(items)
- if assignee?
+ if assignee_id? || assignee_username?
items = items.where(assignee_id: assignee.try(:id))
end
@@ -271,7 +283,7 @@ class IssuableFinder
end
def by_author(items)
- if author?
+ if author_id? || author_username?
items = items.where(author_id: author.try(:id))
end