summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-11-23 19:18:19 +0100
committerRémy Coutable <remy@rymai.me>2016-11-24 10:19:36 +0100
commit4d2e7894efa36cc1b5de9432e25fcf22b6cf1d59 (patch)
treef3fc688746a80361d5688e8bae6d385d22a1c88d /lib/api
parent7100b76923fc88667b1bd22b34f0a43323fe84b0 (diff)
downloadgitlab-ce-4d2e7894efa36cc1b5de9432e25fcf22b6cf1d59.tar.gz
Make API::Helpers find a project with only one query
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 2c593dbb4ea..60067758e95 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -76,7 +76,12 @@ module API
end
def find_project(id)
- project = Project.find_with_namespace(id) || Project.find_by(id: id)
+ project =
+ if id =~ /^\d+$/
+ Project.find_by(id: id)
+ else
+ Project.find_with_namespace(id)
+ end
if can?(current_user, :read_project, project)
project