summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-08-09 06:25:29 +0000
committerRémy Coutable <remy@rymai.me>2019-08-09 06:25:29 +0000
commit44065b0138f5c6de24471a21d8bbdb31604944da (patch)
tree03789c5ec88a921a18408078478da4d32d3de1f3 /lib/api
parent6e33ec1716078609e1a99e3c1a949f2dcb49c63e (diff)
parente6dc5168b86d613e3334fa55618e394308bf55bf (diff)
downloadgitlab-ce-44065b0138f5c6de24471a21d8bbdb31604944da.tar.gz
Merge branch 'speed-up-labels-api' into 'master'
Remove label issue and MR counts from default API responses See merge request gitlab-org/gitlab-ce!31543
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb18
-rw-r--r--lib/api/group_labels.rb2
-rw-r--r--lib/api/helpers/label_helpers.rb6
-rw-r--r--lib/api/labels.rb2
4 files changed, 19 insertions, 9 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 1496b5c5f9e..09253ab6b0e 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -1090,16 +1090,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|
diff --git a/lib/api/group_labels.rb b/lib/api/group_labels.rb
index 0dbc5f45a68..79a44941c81 100644
--- a/lib/api/group_labels.rb
+++ b/lib/api/group_labels.rb
@@ -16,6 +16,8 @@ module API
success Entities::GroupLabel
end
params do
+ optional :with_counts, type: Boolean, default: false,
+ desc: 'Include issue and merge request counts'
use :pagination
end
get ':id/labels' do
diff --git a/lib/api/helpers/label_helpers.rb b/lib/api/helpers/label_helpers.rb
index c11e7d614ab..896b0aba52b 100644
--- a/lib/api/helpers/label_helpers.rb
+++ b/lib/api/helpers/label_helpers.rb
@@ -19,7 +19,11 @@ module API
end
def get_labels(parent, entity)
- present paginate(available_labels_for(parent)), with: entity, current_user: current_user, parent: parent
+ present paginate(available_labels_for(parent)),
+ with: entity,
+ current_user: current_user,
+ parent: parent,
+ with_counts: params[:with_counts]
end
def create_label(parent, entity)
diff --git a/lib/api/labels.rb b/lib/api/labels.rb
index d729d3ee625..c183198d3c6 100644
--- a/lib/api/labels.rb
+++ b/lib/api/labels.rb
@@ -15,6 +15,8 @@ module API
success Entities::ProjectLabel
end
params do
+ optional :with_counts, type: Boolean, default: false,
+ desc: 'Include issue and merge request counts'
use :pagination
end
get ':id/labels' do