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
740dc412
Commit
740dc412
authored
May 14, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'project_api_order' into 'master'
Add order option for projects API
https://dev.gitlab.org/gitlab/gitlab-ci/issues/222
See merge request !656
parents
aa4f0851
74710471
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
projects.md
doc/api/projects.md
+3
-0
projects.rb
lib/api/projects.rb
+6
-1
projects_spec.rb
spec/requests/api/projects_spec.rb
+9
-0
No files found.
doc/api/projects.md
View file @
740dc412
...
@@ -32,6 +32,7 @@ Parameters:
...
@@ -32,6 +32,7 @@ Parameters:
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`ci_enabled_first`
- Return projects ordered by ci_enabled flag. Projects with enabled GitLab CI go first
```
json
```
json
[
[
...
@@ -134,6 +135,7 @@ Parameters:
...
@@ -134,6 +135,7 @@ Parameters:
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`ci_enabled_first`
- Return projects ordered by ci_enabled flag. Projects with enabled GitLab CI go first
### List ALL projects
### List ALL projects
...
@@ -149,6 +151,7 @@ Parameters:
...
@@ -149,6 +151,7 @@ Parameters:
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`order_by`
(optional) - Return requests ordered by
`id`
,
`name`
,
`path`
,
`created_at`
,
`updated_at`
or
`last_activity_at`
fields. Default is
`created_at`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`sort`
(optional) - Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`search`
(optional) - Return list of authorized projects according to a search criteria
-
`ci_enabled_first`
- Return projects ordered by ci_enabled flag. Projects with enabled GitLab CI go first
### Get single project
### Get single project
...
...
lib/api/projects.rb
View file @
740dc412
...
@@ -22,7 +22,12 @@ module API
...
@@ -22,7 +22,12 @@ module API
projects
=
projects
.
search
(
params
[
:search
])
projects
=
projects
.
search
(
params
[
:search
])
end
end
projects
.
reorder
(
project_order_by
=>
project_sort
)
if
params
[
:ci_enabled_first
].
present?
projects
.
includes
(
:gitlab_ci_service
).
reorder
(
"services.active DESC, projects.
#{
project_order_by
}
#{
project_sort
}
"
)
else
projects
.
reorder
(
project_order_by
=>
project_sort
)
end
end
end
def
project_order_by
def
project_order_by
...
...
spec/requests/api/projects_spec.rb
View file @
740dc412
...
@@ -86,6 +86,15 @@ describe API::API, api: true do
...
@@ -86,6 +86,15 @@ describe API::API, api: true do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project3
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project3
.
id
)
end
end
it
'returns projects in the correct order when ci_enabled_first parameter is passed'
do
[
project
,
project2
,
project3
].
each
{
|
project
|
project
.
build_missing_services
}
project2
.
gitlab_ci_service
.
update
(
active:
true
,
token:
"token"
,
project_url:
"url"
)
get
api
(
'/projects'
,
user
),
{
ci_enabled_first:
'true'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project2
.
id
)
end
end
end
end
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