diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-11-07 14:57:16 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-11-07 14:57:16 +0000 |
commit | fadaa3d181b26c420a2424d35780cddc9fc32ce0 (patch) | |
tree | 8f1d3b86319b9c6778d2b1910598763db0624f7b /lib | |
parent | ac8f157301fed1ce83969ff4bb9aa6dc99a895e6 (diff) | |
parent | 4d23090877c2af3634a7f02802fb765d969bd38e (diff) | |
download | gitlab-ce-fadaa3d181b26c420a2424d35780cddc9fc32ce0.tar.gz |
Merge branch 'dm-api-merge-requests-index-merged-at' into 'master'
Expose {closed,merged}_{at,by} in merge requests API index
Closes #52031
See merge request gitlab-org/gitlab-ce!22806
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 32 | ||||
-rw-r--r-- | lib/api/issues.rb | 2 | ||||
-rw-r--r-- | lib/api/merge_requests.rb | 2 |
3 files changed, 18 insertions, 18 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 9f7be27b047..61d57c643f0 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 7909f9c7a00..491b5085bb8 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -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 diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index a617efaaa4c..16f07f16387 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -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 |