BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4d2e7894
Unverified
Commit
4d2e7894
authored
Nov 23, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make API::Helpers find a project with only one query
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
7100b769
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
22373-reduce-queries-in-api-helpers-find_project.yml
...ased/22373-reduce-queries-in-api-helpers-find_project.yml
+4
-0
helpers.rb
lib/api/helpers.rb
+6
-1
No files found.
changelogs/unreleased/22373-reduce-queries-in-api-helpers-find_project.yml
0 → 100644
View file @
4d2e7894
---
title
:
'
Make
API::Helpers
find
a
project
with
only
one
query'
merge_request
:
7714
author
:
lib/api/helpers.rb
View file @
4d2e7894
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment