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
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
projects.md
doc/api/projects.md
+2
-2
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