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
iv
gitlab-ce
Commits
37ed5837
Commit
37ed5837
authored
Dec 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
e0459da2
71ae8570
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
+49
-6
CHANGELOG
CHANGELOG
+1
-1
doc/api/projects.md
doc/api/projects.md
+7
-3
lib/api/projects.rb
lib/api/projects.rb
+41
-2
No files found.
CHANGELOG
View file @
37ed5837
...
...
@@ -19,7 +19,7 @@ v 7.7.0
-
- Add alert message in case of outdated browser (IE < 10)
-
-
-
Added API support for sorting projects
v 7.6.0
- Fork repository to groups
...
...
doc/api/projects.md
View file @
37ed5837
...
...
@@ -11,6 +11,8 @@ GET /projects
Parameters:
-
`archived`
(optional) - if passed, limit by archived status
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`created_at`
or
`last_activity_at`
fields
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order
```
json
[
...
...
@@ -628,6 +630,8 @@ GET /projects/search/:query
Parameters:
-
query (required) - A string contained in the project name
-
per_page (optional) - number of projects to return per page
-
page (optional) - the page to retrieve
-
`query`
(required) - A string contained in the project name
-
`per_page`
(optional) - number of projects to return per page
-
`page`
(optional) - the page to retrieve
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`created_at`
or
`last_activity_at`
fields
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order
lib/api/projects.rb
View file @
37ed5837
...
...
@@ -22,6 +22,15 @@ module API
# GET /projects
get
do
@projects
=
current_user
.
authorized_projects
sort
=
params
[
:sort
]
==
'desc'
?
'desc'
:
'asc'
@projects
=
case
params
[
"order_by"
]
when
'id'
then
@projects
.
reorder
(
"id
#{
sort
}
"
)
when
'name'
then
@projects
.
reorder
(
"name
#{
sort
}
"
)
when
'created_at'
then
@projects
.
reorder
(
"created_at
#{
sort
}
"
)
when
'last_activity_at'
then
@projects
.
reorder
(
"last_activity_at
#{
sort
}
"
)
else
@projects
end
# If the archived parameter is passed, limit results accordingly
if
params
[
:archived
].
present?
...
...
@@ -37,7 +46,17 @@ module API
# Example Request:
# GET /projects/owned
get
'/owned'
do
@projects
=
paginate
current_user
.
owned_projects
sort
=
params
[
:sort
]
==
'desc'
?
'desc'
:
'asc'
@projects
=
current_user
.
owned_projects
@projects
=
case
params
[
"order_by"
]
when
'id'
then
@projects
.
reorder
(
"id
#{
sort
}
"
)
when
'name'
then
@projects
.
reorder
(
"name
#{
sort
}
"
)
when
'created_at'
then
@projects
.
reorder
(
"created_at
#{
sort
}
"
)
when
'last_activity_at'
then
@projects
.
reorder
(
"last_activity_at
#{
sort
}
"
)
else
@projects
end
@projects
=
paginate
@projects
present
@projects
,
with:
Entities
::
Project
end
...
...
@@ -47,7 +66,17 @@ module API
# GET /projects/all
get
'/all'
do
authenticated_as_admin!
@projects
=
paginate
Project
sort
=
params
[
:sort
]
==
'desc'
?
'desc'
:
'asc'
@projects
=
case
params
[
"order_by"
]
when
'id'
then
Project
.
order
(
"id
#{
sort
}
"
)
when
'name'
then
Project
.
order
(
"name
#{
sort
}
"
)
when
'created_at'
then
Project
.
order
(
"created_at
#{
sort
}
"
)
when
'last_activity_at'
then
Project
.
order
(
"last_activity_at
#{
sort
}
"
)
else
Project
end
@projects
=
paginate
@projects
present
@projects
,
with:
Entities
::
Project
end
...
...
@@ -227,6 +256,16 @@ module API
ids
=
current_user
.
authorized_projects
.
map
(
&
:id
)
visibility_levels
=
[
Gitlab
::
VisibilityLevel
::
INTERNAL
,
Gitlab
::
VisibilityLevel
::
PUBLIC
]
projects
=
Project
.
where
(
"(id in (?) OR visibility_level in (?)) AND (name LIKE (?))"
,
ids
,
visibility_levels
,
"%
#{
params
[
:query
]
}
%"
)
sort
=
params
[
:sort
]
==
'desc'
?
'desc'
:
'asc'
projects
=
case
params
[
"order_by"
]
when
'id'
then
projects
.
order
(
"id
#{
sort
}
"
)
when
'name'
then
projects
.
order
(
"name
#{
sort
}
"
)
when
'created_at'
then
projects
.
order
(
"created_at
#{
sort
}
"
)
when
'last_activity_at'
then
projects
.
order
(
"last_activity_at
#{
sort
}
"
)
else
projects
end
present
paginate
(
projects
),
with:
Entities
::
Project
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