Commit 34e8d972 authored by Douwe Maan's avatar Douwe Maan

Expose {closed,merged}_{at,by} in merge requests API index

parent 90473e06
---
title: Expose {closed,merged}_{at,by} in merge requests API index
merge_request:
author:
type: changed
...@@ -57,7 +57,18 @@ Parameters: ...@@ -57,7 +57,18 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"merged_by": {
"id": 87854,
"name": "Douwe Maan",
"username": "DouweM",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png",
"web_url": "https://gitlab.com/DouweM"
},
"merged_at": "2018-09-07T11:16:17.520Z",
"closed_by": null,
"closed_at": null,
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -180,7 +191,18 @@ Parameters: ...@@ -180,7 +191,18 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"merged_by": {
"id": 87854,
"name": "Douwe Maan",
"username": "DouweM",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png",
"web_url": "https://gitlab.com/DouweM"
},
"merged_at": "2018-09-07T11:16:17.520Z",
"closed_by": null,
"closed_at": null,
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -293,7 +315,18 @@ Parameters: ...@@ -293,7 +315,18 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"merged_by": {
"id": 87854,
"name": "Douwe Maan",
"username": "DouweM",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png",
"web_url": "https://gitlab.com/DouweM"
},
"merged_at": "2018-09-07T11:16:17.520Z",
"closed_by": null,
"closed_at": null,
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -383,7 +416,7 @@ Parameters: ...@@ -383,7 +416,7 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -695,7 +728,7 @@ POST /projects/:id/merge_requests ...@@ -695,7 +728,7 @@ POST /projects/:id/merge_requests
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -822,7 +855,7 @@ Must include at least one non-required attribute from above. ...@@ -822,7 +855,7 @@ Must include at least one non-required attribute from above.
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -965,7 +998,7 @@ Parameters: ...@@ -965,7 +998,7 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -1080,7 +1113,7 @@ Parameters: ...@@ -1080,7 +1113,7 @@ Parameters:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -1279,7 +1312,7 @@ Example response: ...@@ -1279,7 +1312,7 @@ Example response:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -1400,7 +1433,7 @@ Example response: ...@@ -1400,7 +1433,7 @@ Example response:
"project_id": 3, "project_id": 3,
"title": "test1", "title": "test1",
"description": "fixed login page css paddings", "description": "fixed login page css paddings",
"state": "opened", "state": "merged",
"created_at": "2017-04-29T08:46:00Z", "created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z", "updated_at": "2017-04-29T08:46:00Z",
"target_branch": "master", "target_branch": "master",
...@@ -1540,7 +1573,7 @@ Example response: ...@@ -1540,7 +1573,7 @@ Example response:
"project_id": 3, "project_id": 3,
"title": "Et voluptas laudantium minus nihil recusandae ut accusamus earum aut non.", "title": "Et voluptas laudantium minus nihil recusandae ut accusamus earum aut non.",
"description": "Veniam sunt nihil modi earum cumque illum delectus. Nihil ad quis distinctio quia. Autem eligendi at quibusdam repellendus.", "description": "Veniam sunt nihil modi earum cumque illum delectus. Nihil ad quis distinctio quia. Autem eligendi at quibusdam repellendus.",
"state": "opened", "state": "merged",
"created_at": "2016-06-17T07:48:04.330Z", "created_at": "2016-06-17T07:48:04.330Z",
"updated_at": "2016-07-01T11:14:15.537Z", "updated_at": "2016-07-01T11:14:15.537Z",
"target_branch": "allow_regex_for_project_skip_ref", "target_branch": "allow_regex_for_project_skip_ref",
......
...@@ -607,6 +607,22 @@ module API ...@@ -607,6 +607,22 @@ module API
end end
class MergeRequestBasic < ProjectEntity class MergeRequestBasic < ProjectEntity
expose :merged_by, using: Entities::UserBasic do |merge_request, _options|
merge_request.metrics&.merged_by
end
expose :merged_at do |merge_request, _options|
merge_request.metrics&.merged_at
end
expose :closed_by, using: Entities::UserBasic do |merge_request, _options|
merge_request.metrics&.latest_closed_by
end
expose :closed_at do |merge_request, _options|
merge_request.metrics&.latest_closed_at
end
expose :title_html, if: -> (_, options) { options[:render_html] } do |entity| expose :title_html, if: -> (_, options) { options[:render_html] } do |entity|
MarkupHelper.markdown_field(entity, :title) MarkupHelper.markdown_field(entity, :title)
end end
...@@ -676,22 +692,6 @@ module API ...@@ -676,22 +692,6 @@ module API
merge_request.merge_request_diff.real_size merge_request.merge_request_diff.real_size
end end
expose :merged_by, using: Entities::UserBasic do |merge_request, _options|
merge_request.metrics&.merged_by
end
expose :merged_at do |merge_request, _options|
merge_request.metrics&.merged_at
end
expose :closed_by, using: Entities::UserBasic do |merge_request, _options|
merge_request.metrics&.latest_closed_by
end
expose :closed_at do |merge_request, _options|
merge_request.metrics&.latest_closed_at
end
expose :latest_build_started_at, if: -> (_, options) { build_available?(options) } do |merge_request, _options| expose :latest_build_started_at, if: -> (_, options) { build_available?(options) } do |merge_request, _options|
merge_request.metrics&.latest_build_started_at merge_request.metrics&.latest_build_started_at
end end
......
...@@ -28,7 +28,7 @@ module API ...@@ -28,7 +28,7 @@ module API
args[:scope] = args[:scope].underscore if args[:scope] args[:scope] = args[:scope].underscore if args[:scope]
issues = IssuesFinder.new(current_user, args).execute issues = IssuesFinder.new(current_user, args).execute
.preload(:assignees, :labels, :notes, :timelogs, :project, :author) .preload(:assignees, :labels, :notes, :timelogs, :project, :author, :closed_by)
issues.reorder(args[:order_by] => args[:sort]) issues.reorder(args[:order_by] => args[:sort])
end end
......
...@@ -45,7 +45,7 @@ module API ...@@ -45,7 +45,7 @@ module API
return merge_requests if args[:view] == 'simple' return merge_requests if args[:view] == 'simple'
merge_requests merge_requests
.preload(:notes, :author, :assignee, :milestone, :latest_merge_request_diff, :labels, :timelogs) .preload(:notes, :author, :assignee, :milestone, :latest_merge_request_diff, :labels, :timelogs, metrics: [:latest_closed_by, :merged_by])
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -9,6 +9,32 @@ ...@@ -9,6 +9,32 @@
"title": { "type": "string" }, "title": { "type": "string" },
"description": { "type": ["string", "null"] }, "description": { "type": ["string", "null"] },
"state": { "type": "string" }, "state": { "type": "string" },
"merged_by": {
"type": ["object", "null"],
"properties": {
"name": { "type": "string" },
"username": { "type": "string" },
"id": { "type": "integer" },
"state": { "type": "string" },
"avatar_url": { "type": "uri" },
"web_url": { "type": "uri" }
},
"additionalProperties": false
},
"merged_at": { "type": ["date", "null"] },
"closed_by": {
"type": ["object", "null"],
"properties": {
"name": { "type": "string" },
"username": { "type": "string" },
"id": { "type": "integer" },
"state": { "type": "string" },
"avatar_url": { "type": "uri" },
"web_url": { "type": "uri" }
},
"additionalProperties": false
},
"closed_at": { "type": ["date", "null"] },
"created_at": { "type": "date" }, "created_at": { "type": "date" },
"updated_at": { "type": "date" }, "updated_at": { "type": "date" },
"target_branch": { "type": "string" }, "target_branch": { "type": "string" },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment