Make API::Helpers find a project with only one query

Signed-off-by: NRémy Coutable <remy@rymai.me>
上级 7100b769
---
title: 'Make API::Helpers find a project with only one query'
merge_request: 7714
author:
...@@ -76,7 +76,12 @@ module API ...@@ -76,7 +76,12 @@ module API
end end
def find_project(id) 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) if can?(current_user, :read_project, project)
project project
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册