summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorPatrick Derichs <pderichs@gitlab.com>2019-02-19 11:30:07 +0000
committerSean McGivern <sean@gitlab.com>2019-02-19 11:30:07 +0000
commit42356201703b806219c86c04c2711ad9f52ce052 (patch)
tree3d6abe94e6adc52843d9584142adab87af12a9a0 /lib/api
parent197641c7d7278a7a8c17e318b08dec876636110a (diff)
downloadgitlab-ce-42356201703b806219c86c04c2711ad9f52ce052.tar.gz
Add related merge request count to api response
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 27da2c2e5ed..9199f898ea0 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -557,6 +557,15 @@ module API
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
issue
end
+
+ expose :merge_requests_count do |issue, options|
+ if options[:issuable_metadata]
+ # Avoids an N+1 query when metadata is included
+ options[:issuable_metadata][issue.id].merge_requests_count
+ else
+ issue.merge_requests_closing_issues.count
+ end
+ end
end
class Issue < IssueBasic