diff options
author | Sean McGivern <sean@gitlab.com> | 2019-08-06 17:27:46 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-08 17:10:41 +0100 |
commit | e6dc5168b86d613e3334fa55618e394308bf55bf (patch) | |
tree | 6ad67848dfbe81949474e20f5224edf055c273cb /lib/api/entities.rb | |
parent | 26087322713e2949f2bf207798512374757a484c (diff) | |
download | gitlab-ce-speed-up-labels-api.tar.gz |
Remove label issue and MR counts from default API responsesspeed-up-labels-api
These counts significantly increase the load time for these
requests. Users can now opt in to receiving the counts by setting
`with_counts=true` in requests. This is a breaking change, but hopefully
a fairly minor one.
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r-- | lib/api/entities.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 2f5ce3d4003..70201502b57 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1085,16 +1085,18 @@ module API end class Label < LabelBasic - expose :open_issues_count do |label, options| - label.open_issues_count(options[:current_user]) - end + with_options if: lambda { |_, options| options[:with_counts] } do + expose :open_issues_count do |label, options| + label.open_issues_count(options[:current_user]) + end - expose :closed_issues_count do |label, options| - label.closed_issues_count(options[:current_user]) - end + expose :closed_issues_count do |label, options| + label.closed_issues_count(options[:current_user]) + end - expose :open_merge_requests_count do |label, options| - label.open_merge_requests_count(options[:current_user]) + expose :open_merge_requests_count do |label, options| + label.open_merge_requests_count(options[:current_user]) + end end expose :subscribed do |label, options| |