summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorAlexandru Croitor <acroitor@gitlab.com>2019-06-12 19:28:25 +0300
committerAlexandru Croitor <acroitor@gitlab.com>2019-06-18 12:46:46 +0300
commit09163e423ac50c8eda82f67e5419142893faf18a (patch)
tree91f687ddb99fd03db7894c238759eea086029d51 /lib/api/entities.rb
parente5ca7b8b0b5ba45f5847b6e545d17ca5af1cd929 (diff)
downloadgitlab-ce-09163e423ac50c8eda82f67e5419142893faf18a.tar.gz
Expose merge requests count based on user access
Count issues related merge requests based on user access level. And issue can have related MRs from projects where user does not have access so the number of related merge requests should be adjusted based on user's ability to access the related MRs. https://gitlab.com/gitlab-org/gitlab-ce/issues/59581
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 25e9fdd5fce..9c7a7fad742 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -498,9 +498,9 @@ module API
expose :state, :created_at, :updated_at
# Avoids an N+1 query when metadata is included
- def issuable_metadata(subject, options, method)
+ def issuable_metadata(subject, options, method, args = nil)
cached_subject = options.dig(:issuable_metadata, subject.id)
- (cached_subject || subject).public_send(method) # rubocop: disable GitlabSecurity/PublicSend
+ (cached_subject || subject).public_send(method, *args) # rubocop: disable GitlabSecurity/PublicSend
end
end
@@ -564,7 +564,7 @@ module API
end
expose(:user_notes_count) { |issue, options| issuable_metadata(issue, options, :user_notes_count) }
- expose(:merge_requests_count) { |issue, options| issuable_metadata(issue, options, :merge_requests_count) }
+ expose(:merge_requests_count) { |issue, options| issuable_metadata(issue, options, :merge_requests_count, options[:current_user]) }
expose(:upvotes) { |issue, options| issuable_metadata(issue, options, :upvotes) }
expose(:downvotes) { |issue, options| issuable_metadata(issue, options, :downvotes) }
expose :due_date