diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /app/graphql/types/merge_request_type.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/graphql/types/merge_request_type.rb')
-rw-r--r-- | app/graphql/types/merge_request_type.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index 56c88491684..372aeac055b 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -152,6 +152,25 @@ module Types field :auto_merge_enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates if auto merge is enabled for the merge request' + field :approved_by, Types::UserType.connection_type, null: true, + description: 'Users who approved the merge request' + + def approved_by + object.approved_by_users + end + + # rubocop: disable CodeReuse/ActiveRecord + def user_notes_count + BatchLoader::GraphQL.for(object.id).batch(key: :merge_request_user_notes_count) do |ids, loader, args| + counts = Note.where(noteable_type: 'MergeRequest', noteable_id: ids).user.group(:noteable_id).count + + ids.each do |id| + loader.call(id, counts[id] || 0) + end + end + end + # rubocop: enable CodeReuse/ActiveRecord + def diff_stats(path: nil) stats = Array.wrap(object.diff_stats&.to_a) @@ -163,21 +182,12 @@ module Types end def diff_stats_summary - nil_stats = { additions: 0, deletions: 0, file_count: 0 } - return nil_stats unless object.diff_stats.present? - - object.diff_stats.each_with_object(nil_stats) do |status, hash| - hash.merge!(additions: status.additions, deletions: status.deletions, file_count: 1) { |_, x, y| x + y } - end + BatchLoaders::MergeRequestDiffSummaryBatchLoader.load_for(object) end def commit_count object&.metrics&.commits_count end - - def approvers - object.approver_users - end end end Types::MergeRequestType.prepend_if_ee('::EE::Types::MergeRequestType') |