Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities/merge_request.rb')
-rw-r--r--lib/api/entities/merge_request.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/api/entities/merge_request.rb b/lib/api/entities/merge_request.rb
index 9ff8e20ced1..7fc76a4071e 100644
--- a/lib/api/entities/merge_request.rb
+++ b/lib/api/entities/merge_request.rb
@@ -39,6 +39,16 @@ module API
expose :diverged_commits_count, as: :diverged_commits_count, if: -> (_, options) { options[:include_diverged_commits_count] }
+ # We put this into an option because list of TODOs API will attach their
+ # targets with Entities::MergeRequest instead of
+ # Entities::MergeRequestBasic, but this attribute cannot be eagerly
+ # loaded in batch for now. The list of merge requests API will
+ # use Entities::MergeRequestBasic which does not support this, and
+ # we always enable this for the single merge request API. This way
+ # we avoid N+1 queries in the TODOs API and can still enable it for
+ # the single merge request API.
+ expose :first_contribution?, as: :first_contribution, if: -> (_, options) { options[:include_first_contribution] }
+
def build_available?(options)
options[:project]&.feature_available?(:builds, options[:current_user])
end