BigW Consortium Gitlab

Commit ed23957d by Sean McGivern Committed by Oswaldo Ferreira

Merge branch 'dm-batchloader-project' into 'master'

Include project in BatchLoader key to prevent returning blobs for the wrong project Closes gitlab-ee#4325 See merge request gitlab-org/gitlab-ce!15936 (cherry picked from commit f5114187) 6c4f6d37 Include project in BatchLoader key to prevent returning blobs for the wrong project f871027e Clear BatchLoader after each spec to prevent holding onto records longer than necessary
parent f95acda0
......@@ -77,9 +77,15 @@ class Blob < SimpleDelegator
end
def self.lazy(project, commit_id, path)
BatchLoader.for(commit_id: commit_id, path: path).batch do |items, loader|
project.repository.blobs_at(items.map(&:values)).each do |blob|
loader.call({ commit_id: blob.commit_id, path: blob.path }, blob) if blob
BatchLoader.for({ project: project, commit_id: commit_id, path: path }).batch do |items, loader|
items_by_project = items.group_by { |i| i[:project] }
items_by_project.each do |project, items|
items = items.map { |i| i.values_at(:commit_id, :path) }
project.repository.blobs_at(items).each do |blob|
loader.call({ project: blob.project, commit_id: blob.commit_id, path: blob.path }, blob) if blob
end
end
end
end
......
RSpec.configure do |config|
config.after do
BatchLoader::Executor.clear_current
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment