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
42356201
Commit
42356201
authored
Feb 19, 2019
by
Patrick Derichs
Committed by
Sean McGivern
Feb 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add related merge request count to api response
parent
197641c7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
changelogs/unreleased/add-related-merge-request-count-to-api-response.yml
...eased/add-related-merge-request-count-to-api-response.yml
+5
-0
doc/api/issues.md
doc/api/issues.md
+10
-0
lib/api/entities.rb
lib/api/entities.rb
+9
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+18
-0
No files found.
changelogs/unreleased/add-related-merge-request-count-to-api-response.yml
0 → 100644
View file @
42356201
---
title
:
Add related merge request count to api response
merge_request
:
24974
author
:
type
:
added
doc/api/issues.md
View file @
42356201
...
@@ -110,6 +110,7 @@ Example response:
...
@@ -110,6 +110,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"user_notes_count"
:
1
,
"user_notes_count"
:
1
,
"due_date"
:
"2016-07-22"
,
"due_date"
:
"2016-07-22"
,
"web_url"
:
"http://example.com/example/example/issues/6"
,
"web_url"
:
"http://example.com/example/example/issues/6"
,
...
@@ -219,6 +220,7 @@ Example response:
...
@@ -219,6 +220,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"id"
:
41
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
@@ -334,6 +336,7 @@ Example response:
...
@@ -334,6 +336,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"id"
:
41
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
@@ -430,6 +433,7 @@ Example response:
...
@@ -430,6 +433,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"id"
:
41
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
@@ -505,6 +509,7 @@ Example response:
...
@@ -505,6 +509,7 @@ Example response:
],
],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"author"
:
{
"author"
:
{
"name"
:
"Alexandra Bashirian"
,
"name"
:
"Alexandra Bashirian"
,
"avatar_url"
:
null
,
"avatar_url"
:
null
,
...
@@ -604,6 +609,7 @@ Example response:
...
@@ -604,6 +609,7 @@ Example response:
],
],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"id"
:
85
,
"id"
:
85
,
"assignees"
:
[],
"assignees"
:
[],
"assignee"
:
null
,
"assignee"
:
null
,
...
@@ -690,6 +696,7 @@ Example response:
...
@@ -690,6 +696,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"milestone"
:
null
,
"milestone"
:
null
,
"assignees"
:
[{
"assignees"
:
[{
"name"
:
"Miss Monserrate Beier"
,
"name"
:
"Miss Monserrate Beier"
,
...
@@ -774,6 +781,7 @@ Example response:
...
@@ -774,6 +781,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"milestone"
:
null
,
"milestone"
:
null
,
"assignees"
:
[{
"assignees"
:
[{
"name"
:
"Miss Monserrate Beier"
,
"name"
:
"Miss Monserrate Beier"
,
...
@@ -856,6 +864,7 @@ Example response:
...
@@ -856,6 +864,7 @@ Example response:
"labels"
:
[],
"labels"
:
[],
"upvotes"
:
4
,
"upvotes"
:
4
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"milestone"
:
null
,
"milestone"
:
null
,
"assignee"
:
{
"assignee"
:
{
"name"
:
"Edwardo Grady"
,
"name"
:
"Edwardo Grady"
,
...
@@ -973,6 +982,7 @@ Example response:
...
@@ -973,6 +982,7 @@ Example response:
"user_notes_count"
:
7
,
"user_notes_count"
:
7
,
"upvotes"
:
0
,
"upvotes"
:
0
,
"downvotes"
:
0
,
"downvotes"
:
0
,
"merge_requests_count"
:
0
,
"due_date"
:
null
,
"due_date"
:
null
,
"web_url"
:
"http://example.com/example/example/issues/110"
,
"web_url"
:
"http://example.com/example/example/issues/110"
,
"confidential"
:
false
,
"confidential"
:
false
,
...
...
lib/api/entities.rb
View file @
42356201
...
@@ -557,6 +557,15 @@ module API
...
@@ -557,6 +557,15 @@ module API
expose
:time_stats
,
using:
'API::Entities::IssuableTimeStats'
do
|
issue
|
expose
:time_stats
,
using:
'API::Entities::IssuableTimeStats'
do
|
issue
|
issue
issue
end
end
expose
:merge_requests_count
do
|
issue
,
options
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
issue
.
id
].
merge_requests_count
else
issue
.
merge_requests_closing_issues
.
count
end
end
end
end
class
Issue
<
IssueBasic
class
Issue
<
IssueBasic
...
...
spec/requests/api/issues_spec.rb
View file @
42356201
...
@@ -421,6 +421,24 @@ describe API::Issues do
...
@@ -421,6 +421,24 @@ describe API::Issues do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/issues'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/issues'
)
end
end
it
'returns a related merge request count of 0 if there are no related merge requests'
do
get
api
(
'/issues'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/issues'
)
expect
(
json_response
.
first
).
to
include
(
'merge_requests_count'
=>
0
)
end
it
'returns a related merge request count > 0 if there are related merge requests'
do
create
(
:merge_requests_closing_issues
,
issue:
issue
)
get
api
(
'/issues'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/issues'
)
expect
(
json_response
.
first
).
to
include
(
'merge_requests_count'
=>
1
)
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