Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
04c7c262
Commit
04c7c262
authored
Sep 24, 2013
by
Izaak Alpert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used pagnation function from api helpers
Change-Id: I1bdd3608d3b46924b5da3ae282c99f85ee4e0dab
parent
9d06921f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
doc/api/projects.md
doc/api/projects.md
+2
-2
lib/api/projects.rb
lib/api/projects.rb
+4
-6
No files found.
doc/api/projects.md
View file @
04c7c262
...
...
@@ -497,5 +497,5 @@ GET /projects/search/:query
Parameters:
+
query (required) - A string contained in the project name
+
per_page (optional) - number of projects to return per page
, defaults to 20
+
offset (optional) - the offset in pages
to retrieve
+
per_page (optional) - number of projects to return per page
+
page (optional) - the page
to retrieve
lib/api/projects.rb
View file @
04c7c262
...
...
@@ -266,16 +266,14 @@ module API
#
# Parameters:
# query (required) - A string contained in the project name
# per_page (optional) - number of projects to return per page
, defaults to 20
#
offset (optional) - the offset in pages
to retrieve
# per_page (optional) - number of projects to return per page
#
page (optional) - the page
to retrieve
# Example Request:
# GET /projects/search/:query
get
"/search/:query"
do
limit
=
(
params
[
:per_page
]
||
20
).
to_i
offset
=
(
params
[
:page
]
||
0
).
to_i
*
limit
ids
=
current_user
.
authorized_projects
.
map
(
&
:id
)
projects
=
Project
.
where
(
"(id in (?) OR public = true) AND (name LIKE (?))"
,
ids
,
"%
#{
params
[
:query
]
}
%"
)
.
limit
(
limit
).
offset
(
offset
)
present
p
rojects
,
with:
Entities
::
Project
projects
=
Project
.
where
(
"(id in (?) OR public = true) AND (name LIKE (?))"
,
ids
,
"%
#{
params
[
:query
]
}
%"
)
present
p
aginate
(
projects
)
,
with:
Entities
::
Project
end
end
end
...
...
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