Expose {closed,merged}_{at,by} in merge requests API index
This commit is contained in:
parent
90473e064e
commit
34e8d9726d
6 changed files with 93 additions and 29 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Expose {closed,merged}_{at,by} in merge requests API index
|
||||
merge_request:
|
||||
author:
|
||||
type: changed
|
|
@ -57,7 +57,18 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"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",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -180,7 +191,18 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"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",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -293,7 +315,18 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"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",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -383,7 +416,7 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -695,7 +728,7 @@ POST /projects/:id/merge_requests
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -822,7 +855,7 @@ Must include at least one non-required attribute from above.
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -965,7 +998,7 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -1080,7 +1113,7 @@ Parameters:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -1279,7 +1312,7 @@ Example response:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -1400,7 +1433,7 @@ Example response:
|
|||
"project_id": 3,
|
||||
"title": "test1",
|
||||
"description": "fixed login page css paddings",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2017-04-29T08:46:00Z",
|
||||
"updated_at": "2017-04-29T08:46:00Z",
|
||||
"target_branch": "master",
|
||||
|
@ -1540,7 +1573,7 @@ Example response:
|
|||
"project_id": 3,
|
||||
"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.",
|
||||
"state": "opened",
|
||||
"state": "merged",
|
||||
"created_at": "2016-06-17T07:48:04.330Z",
|
||||
"updated_at": "2016-07-01T11:14:15.537Z",
|
||||
"target_branch": "allow_regex_for_project_skip_ref",
|
||||
|
|
|
@ -607,6 +607,22 @@ module API
|
|||
end
|
||||
|
||||
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|
|
||||
MarkupHelper.markdown_field(entity, :title)
|
||||
end
|
||||
|
@ -676,22 +692,6 @@ module API
|
|||
merge_request.merge_request_diff.real_size
|
||||
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|
|
||||
merge_request.metrics&.latest_build_started_at
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ module API
|
|||
args[:scope] = args[:scope].underscore if args[:scope]
|
||||
|
||||
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])
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module API
|
|||
return merge_requests if args[:view] == 'simple'
|
||||
|
||||
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
|
||||
# rubocop: enable CodeReuse/ActiveRecord
|
||||
|
||||
|
|
|
@ -9,6 +9,32 @@
|
|||
"title": { "type": "string" },
|
||||
"description": { "type": ["string", "null"] },
|
||||
"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" },
|
||||
"updated_at": { "type": "date" },
|
||||
"target_branch": { "type": "string" },
|
||||
|
|
Loading…
Reference in a new issue