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
3328f097
Commit
3328f097
authored
Feb 13, 2019
by
Robert Schilling
Committed by
Rémy Coutable
Feb 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add milestone progress to API
parent
c0fa62b5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
4 deletions
+20
-4
changelogs/unreleased/50559-add-milestone-progress-to-api.yml
...gelogs/unreleased/50559-add-milestone-progress-to-api.yml
+5
-0
doc/api/group_milestones.md
doc/api/group_milestones.md
+1
-0
doc/api/milestones.md
doc/api/milestones.md
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+3
-0
lib/api/milestone_responses.rb
lib/api/milestone_responses.rb
+4
-4
spec/fixtures/api/schemas/public_api/v4/milestone.json
spec/fixtures/api/schemas/public_api/v4/milestone.json
+1
-0
spec/support/api/milestones_shared_examples.rb
spec/support/api/milestones_shared_examples.rb
+5
-0
No files found.
changelogs/unreleased/50559-add-milestone-progress-to-api.yml
0 → 100644
View file @
3328f097
---
title
:
'
API:
Expose
milestone
progress'
merge_request
:
25173
author
:
Robert Schilling
type
:
added
doc/api/group_milestones.md
View file @
3328f097
...
@@ -42,6 +42,7 @@ Example Response:
...
@@ -42,6 +42,7 @@ Example Response:
"due_date"
:
"2013-11-29"
,
"due_date"
:
"2013-11-29"
,
"start_date"
:
"2013-11-10"
,
"start_date"
:
"2013-11-10"
,
"state"
:
"active"
,
"state"
:
"active"
,
"percentage_complete"
:
66
,
"updated_at"
:
"2013-10-02T09:24:18Z"
,
"updated_at"
:
"2013-10-02T09:24:18Z"
,
"created_at"
:
"2013-10-02T09:24:18Z"
"created_at"
:
"2013-10-02T09:24:18Z"
}
}
...
...
doc/api/milestones.md
View file @
3328f097
...
@@ -39,6 +39,7 @@ Example Response:
...
@@ -39,6 +39,7 @@ Example Response:
"due_date"
:
"2013-11-29"
,
"due_date"
:
"2013-11-29"
,
"start_date"
:
"2013-11-10"
,
"start_date"
:
"2013-11-10"
,
"state"
:
"active"
,
"state"
:
"active"
,
"percentage_complete"
:
66
,
"updated_at"
:
"2013-10-02T09:24:18Z"
,
"updated_at"
:
"2013-10-02T09:24:18Z"
,
"created_at"
:
"2013-10-02T09:24:18Z"
"created_at"
:
"2013-10-02T09:24:18Z"
}
}
...
...
lib/api/entities.rb
View file @
3328f097
...
@@ -501,6 +501,9 @@ module API
...
@@ -501,6 +501,9 @@ module API
expose
:state
,
:created_at
,
:updated_at
expose
:state
,
:created_at
,
:updated_at
expose
:due_date
expose
:due_date
expose
:start_date
expose
:start_date
expose
:percentage_complete
do
|
milestone
,
options
|
milestone
.
percent_complete
(
options
[
:current_user
])
end
expose
:web_url
do
|
milestone
,
_options
|
expose
:web_url
do
|
milestone
,
_options
|
Gitlab
::
UrlBuilder
.
build
(
milestone
)
Gitlab
::
UrlBuilder
.
build
(
milestone
)
...
...
lib/api/milestone_responses.rb
View file @
3328f097
...
@@ -35,19 +35,19 @@ module API
...
@@ -35,19 +35,19 @@ module API
milestones
=
filter_by_iid
(
milestones
,
params
[
:iids
])
if
params
[
:iids
].
present?
milestones
=
filter_by_iid
(
milestones
,
params
[
:iids
])
if
params
[
:iids
].
present?
milestones
=
filter_by_search
(
milestones
,
params
[
:search
])
if
params
[
:search
]
milestones
=
filter_by_search
(
milestones
,
params
[
:search
])
if
params
[
:search
]
present
paginate
(
milestones
),
with:
Entities
::
Milestone
present
paginate
(
milestones
),
with:
Entities
::
Milestone
,
current_user:
current_user
end
end
def
get_milestone_for
(
parent
)
def
get_milestone_for
(
parent
)
milestone
=
parent
.
milestones
.
find
(
params
[
:milestone_id
])
milestone
=
parent
.
milestones
.
find
(
params
[
:milestone_id
])
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
,
current_user:
current_user
end
end
def
create_milestone_for
(
parent
)
def
create_milestone_for
(
parent
)
milestone
=
::
Milestones
::
CreateService
.
new
(
parent
,
current_user
,
declared_params
).
execute
milestone
=
::
Milestones
::
CreateService
.
new
(
parent
,
current_user
,
declared_params
).
execute
if
milestone
.
valid?
if
milestone
.
valid?
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
,
current_user:
current_user
else
else
render_api_error!
(
"Failed to create milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
render_api_error!
(
"Failed to create milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
end
end
...
@@ -60,7 +60,7 @@ module API
...
@@ -60,7 +60,7 @@ module API
milestone
=
::
Milestones
::
UpdateService
.
new
(
parent
,
current_user
,
milestone_params
).
execute
(
milestone
)
milestone
=
::
Milestones
::
UpdateService
.
new
(
parent
,
current_user
,
milestone_params
).
execute
(
milestone
)
if
milestone
.
valid?
if
milestone
.
valid?
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
,
current_user:
current_user
else
else
render_api_error!
(
"Failed to update milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
render_api_error!
(
"Failed to update milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
end
end
...
...
spec/fixtures/api/schemas/public_api/v4/milestone.json
View file @
3328f097
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
"title"
:
{
"type"
:
"string"
},
"title"
:
{
"type"
:
"string"
},
"description"
:
{
"type"
:
[
"string"
,
"null"
]
},
"description"
:
{
"type"
:
[
"string"
,
"null"
]
},
"state"
:
{
"type"
:
"string"
},
"state"
:
{
"type"
:
"string"
},
"percentage_complete"
:
{
"type"
:
"integer"
},
"created_at"
:
{
"type"
:
"date"
},
"created_at"
:
{
"type"
:
"date"
},
"updated_at"
:
{
"type"
:
"date"
},
"updated_at"
:
{
"type"
:
"date"
},
"start_date"
:
{
"type"
:
"date"
},
"start_date"
:
{
"type"
:
"date"
},
...
...
spec/support/api/milestones_shared_examples.rb
View file @
3328f097
...
@@ -8,12 +8,17 @@ shared_examples_for 'group and project milestones' do |route_definition|
...
@@ -8,12 +8,17 @@ shared_examples_for 'group and project milestones' do |route_definition|
describe
"GET
#{
route_definition
}
"
do
describe
"GET
#{
route_definition
}
"
do
it
'returns milestones list'
do
it
'returns milestones list'
do
create
(
:issue
,
project:
project
,
milestone:
milestone
)
create
(
:closed_issue
,
project:
project
,
milestone:
milestone
)
create
(
:closed_issue
,
project:
project
,
milestone:
milestone
)
get
api
(
route
,
user
)
get
api
(
route
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
milestone
.
title
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
milestone
.
title
)
expect
(
json_response
.
first
[
'percentage_complete'
]).
to
eq
(
66
)
end
end
it
'returns a 401 error if user not authenticated'
do
it
'returns a 401 error if user not authenticated'
do
...
...
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