summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/commit.rb28
-rw-r--r--lib/gitlab/git/tag.rb14
2 files changed, 9 insertions, 33 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 4f05c4b73a1..5863815ca85 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -155,17 +155,9 @@ module Gitlab
end
def extract_signature_lazily(repository, commit_id)
- BatchLoader.for({ repository: repository, commit_id: commit_id }).batch do |items, loader|
- items_by_repo = items.group_by { |i| i[:repository] }
-
- items_by_repo.each do |repo, items|
- commit_ids = items.map { |i| i[:commit_id] }
-
- signatures = batch_signature_extraction(repository, commit_ids)
-
- signatures.each do |commit_sha, signature_data|
- loader.call({ repository: repository, commit_id: commit_sha }, signature_data)
- end
+ BatchLoader.for(commit_id).batch(key: repository) do |commit_ids, loader, args|
+ batch_signature_extraction(args[:key], commit_ids).each do |commit_id, signature_data|
+ loader.call(commit_id, signature_data)
end
end
end
@@ -175,17 +167,9 @@ module Gitlab
end
def get_message(repository, commit_id)
- BatchLoader.for({ repository: repository, commit_id: commit_id }).batch do |items, loader|
- items_by_repo = items.group_by { |i| i[:repository] }
-
- items_by_repo.each do |repo, items|
- commit_ids = items.map { |i| i[:commit_id] }
-
- messages = get_messages(repository, commit_ids)
-
- messages.each do |commit_sha, message|
- loader.call({ repository: repository, commit_id: commit_sha }, message)
- end
+ BatchLoader.for(commit_id).batch(key: repository) do |commit_ids, loader, args|
+ get_messages(args[:key], commit_ids).each do |commit_id, message|
+ loader.call(commit_id, message)
end
end
end
diff --git a/lib/gitlab/git/tag.rb b/lib/gitlab/git/tag.rb
index ade708d0541..23d989ff258 100644
--- a/lib/gitlab/git/tag.rb
+++ b/lib/gitlab/git/tag.rb
@@ -14,17 +14,9 @@ module Gitlab
class << self
def get_message(repository, tag_id)
- BatchLoader.for({ repository: repository, tag_id: tag_id }).batch do |items, loader|
- items_by_repo = items.group_by { |i| i[:repository] }
-
- items_by_repo.each do |repo, items|
- tag_ids = items.map { |i| i[:tag_id] }
-
- messages = get_messages(repository, tag_ids)
-
- messages.each do |id, message|
- loader.call({ repository: repository, tag_id: id }, message)
- end
+ BatchLoader.for(tag_id).batch(key: repository) do |tag_ids, loader, args|
+ get_messages(args[:key], tag_ids).each do |tag_id, message|
+ loader.call(tag_id, message)
end
end
end