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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-27 15:06:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-27 15:06:30 +0300
commit3269a20692c5b1f32862072d7897a4e753bae9ef (patch)
tree9dfc6e7ccb857b323dc8b12259d339b76b8b90bf /app/models/merge_request_diff.rb
parentc02f53288a838166a28518983fae3b80ca5936d8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/merge_request_diff.rb')
-rw-r--r--app/models/merge_request_diff.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index e91a529fecc..06a9a6ee873 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -10,6 +10,7 @@ class MergeRequestDiff < ApplicationRecord
# Don't display more than 100 commits at once
COMMITS_SAFE_SIZE = 100
+ BATCH_SIZE = 1000
# Applies to closed or merged MRs when determining whether to migrate their
# diffs to external storage
@@ -254,10 +255,14 @@ class MergeRequestDiff < ApplicationRecord
merge_request_diff_commits.limit(limit).pluck(:sha)
end
- def commits_by_shas(shas)
- return MergeRequestDiffCommit.none unless shas.present?
+ def includes_any_commits?(shas)
+ return false if shas.blank?
- merge_request_diff_commits.where(sha: shas)
+ # when the number of shas is huge (1000+) we don't want
+ # to pass them all as an SQL param, let's pass them in batches
+ shas.each_slice(BATCH_SIZE).any? do |batched_shas|
+ merge_request_diff_commits.where(sha: batched_shas).exists?
+ end
end
def diff_refs=(new_diff_refs)