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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6b1881b1
Commit
6b1881b1
authored
Jan 22, 2019
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add upvote/downvote counts to Epics API
Includes upvotes/downvotes counts on the epics API endpoints
parent
a75a63cf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
6 deletions
+73
-6
doc/api/epics.md
doc/api/epics.md
+12
-4
doc/api/issues.md
doc/api/issues.md
+18
-0
ee/changelogs/unreleased/6769-epics-votes.yml
ee/changelogs/unreleased/6769-epics-votes.yml
+5
-0
ee/lib/api/epics.rb
ee/lib/api/epics.rb
+4
-2
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+16
-0
ee/spec/fixtures/api/schemas/public_api/v4/epic.json
ee/spec/fixtures/api/schemas/public_api/v4/epic.json
+2
-0
ee/spec/fixtures/api/schemas/public_api/v4/epic_issue_link.json
...c/fixtures/api/schemas/public_api/v4/epic_issue_link.json
+2
-0
ee/spec/requests/api/epics_spec.rb
ee/spec/requests/api/epics_spec.rb
+14
-0
No files found.
doc/api/epics.md
View file @
6b1881b1
...
...
@@ -79,7 +79,9 @@ Example response:
"due_date_from_milestones"
:
"2018-07-31"
,
"created_at"
:
"2018-07-17T13:36:22.770Z"
,
"updated_at"
:
"2018-07-18T12:22:05.239Z"
,
"labels"
:
[]
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
}
]
```
...
...
@@ -129,7 +131,9 @@ Example response:
"due_date_from_milestones"
:
"2018-07-31"
,
"created_at"
:
"2018-07-17T13:36:22.770Z"
,
"updated_at"
:
"2018-07-18T12:22:05.239Z"
,
"labels"
:
[]
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
}
```
...
...
@@ -189,7 +193,9 @@ Example response:
"due_date_from_milestones"
:
"2018-07-31"
,
"created_at"
:
"2018-07-17T13:36:22.770Z"
,
"updated_at"
:
"2018-07-18T12:22:05.239Z"
,
"labels"
:
[]
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
}
```
...
...
@@ -251,7 +257,9 @@ Example response:
"due_date_from_milestones"
:
"2018-07-31"
,
"created_at"
:
"2018-07-17T13:36:22.770Z"
,
"updated_at"
:
"2018-07-18T12:22:05.239Z"
,
"labels"
:
[]
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
}
```
...
...
doc/api/issues.md
View file @
6b1881b1
...
...
@@ -107,6 +107,8 @@ Example response:
"created_at"
:
"2016-01-04T15:31:51.081Z"
,
"iid"
:
6
,
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"user_notes_count"
:
1
,
"due_date"
:
"2016-07-22"
,
"web_url"
:
"http://example.com/example/example/issues/6"
,
...
...
@@ -217,6 +219,8 @@ Example response:
"name"
:
"Dr. Luella Kovacek"
},
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
...
@@ -332,6 +336,8 @@ Example response:
"name"
:
"Dr. Luella Kovacek"
},
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
...
@@ -427,6 +433,8 @@ Example response:
"name"
:
"Dr. Luella Kovacek"
},
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"id"
:
41
,
"title"
:
"Ut commodi ullam eos dolores perferendis nihil sunt."
,
"updated_at"
:
"2016-01-04T15:31:46.176Z"
,
...
...
@@ -502,6 +510,8 @@ Example response:
"labels"
:
[
"bug"
],
"upvotes"
:
4
,
"downvotes"
:
0
,
"author"
:
{
"name"
:
"Alexandra Bashirian"
,
"avatar_url"
:
null
,
...
...
@@ -601,6 +611,8 @@ Example response:
"labels"
:
[
"bug"
],
"upvotes"
:
4
,
"downvotes"
:
0
,
"id"
:
85
,
"assignees"
:
[],
"assignee"
:
null
,
...
...
@@ -686,6 +698,8 @@ Example response:
"closed_at"
:
null
,
"closed_by"
:
null
,
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"milestone"
:
null
,
"assignees"
:
[{
"name"
:
"Miss Monserrate Beier"
,
...
...
@@ -769,6 +783,8 @@ Example response:
"closed_at"
:
null
,
"closed_by"
:
null
,
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"milestone"
:
null
,
"assignees"
:
[{
"name"
:
"Miss Monserrate Beier"
,
...
...
@@ -851,6 +867,8 @@ Example response:
"created_at"
:
"2016-04-05T21:41:45.217Z"
,
"updated_at"
:
"2016-04-07T13:02:37.905Z"
,
"labels"
:
[],
"upvotes"
:
4
,
"downvotes"
:
0
,
"milestone"
:
null
,
"assignee"
:
{
"name"
:
"Edwardo Grady"
,
...
...
ee/changelogs/unreleased/6769-epics-votes.yml
0 → 100644
View file @
6b1881b1
---
title
:
Add upvote/downvote information to epics API
merge_request
:
9264
author
:
type
:
added
ee/lib/api/epics.rb
View file @
6b1881b1
...
...
@@ -9,6 +9,8 @@ module API
authorize_epics_feature!
end
helpers
::
Gitlab
::
IssuableMetadata
helpers
do
def
authorize_epics_feature!
forbidden!
unless
user_group
.
feature_available?
(
:epics
)
...
...
@@ -69,9 +71,9 @@ module API
use
:pagination
end
get
':id/(-/)epics'
do
epics
=
find_epics
(
group_id:
user_group
.
id
)
epics
=
paginate
(
find_epics
(
group_id:
user_group
.
id
)
)
present
paginate
(
epics
),
with:
EE
::
API
::
Entities
::
Epic
,
user:
current_user
present
epics
,
with:
EE
::
API
::
Entities
::
Epic
,
user:
current_user
,
epics_metadata:
issuable_meta_data
(
epics
,
'Epic'
)
end
desc
'Get details of an epic'
do
...
...
ee/lib/ee/api/entities.rb
View file @
6b1881b1
...
...
@@ -203,6 +203,22 @@ module EE
# Avoids an N+1 query since labels are preloaded
epic
.
labels
.
map
(
&
:title
).
sort
end
expose
:upvotes
do
|
epic
,
options
|
if
options
[
:epics_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:epics_metadata
][
epic
.
id
].
upvotes
else
epic
.
upvotes
end
end
expose
:downvotes
do
|
epic
,
options
|
if
options
[
:epics_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:epics_metadata
][
epic
.
id
].
downvotes
else
epic
.
downvotes
end
end
end
class
EpicIssue
<
::
API
::
Entities
::
Issue
...
...
ee/spec/fixtures/api/schemas/public_api/v4/epic.json
View file @
6b1881b1
...
...
@@ -24,6 +24,8 @@
"type"
:
"string"
}
},
"upvotes"
:
{
"type"
:
"integer"
},
"downvotes"
:
{
"type"
:
"integer"
},
"start_date"
:
{
"type"
:
[
"date"
,
"null"
]
},
"start_date_fixed"
:
{
"type"
:
[
"date"
,
"null"
]
},
"start_date_from_milestones"
:
{
"type"
:
[
"date"
,
"null"
]
},
...
...
ee/spec/fixtures/api/schemas/public_api/v4/epic_issue_link.json
View file @
6b1881b1
...
...
@@ -28,6 +28,8 @@
"due_date_from_milestones"
:
{
"type"
:
[
"date"
,
"null"
]
},
"due_date_is_fixed"
:
{
"type"
:
"boolean"
},
"state"
:
{
"type"
:
"string"
},
"upvotes"
:
{
"type"
:
"integer"
},
"downvotes"
:
{
"type"
:
"integer"
},
"created_at"
:
{
"type"
:
[
"string"
,
"null"
]
},
"updated_at"
:
{
"type"
:
[
"string"
,
"null"
]
},
"labels"
:
{
...
...
ee/spec/requests/api/epics_spec.rb
View file @
6b1881b1
...
...
@@ -142,6 +142,20 @@ describe API::Epics do
expect_paginated_array_response
([
epic2
.
id
,
epic
.
id
])
end
it
'has upvote/downvote information'
do
epic
.
create_award_emoji
(
'thumbsup'
,
user
)
epic2
.
create_award_emoji
(
'thumbsdown'
,
user
)
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
contain_exactly
(
a_hash_including
(
'upvotes'
=>
1
,
'downvotes'
=>
0
),
a_hash_including
(
'upvotes'
=>
0
,
'downvotes'
=>
1
)
)
end
it
'sorts by created_at descending by default'
do
get
api
(
url
,
user
)
...
...
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