diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-12-06 09:39:13 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-12-06 09:39:13 +0000 |
commit | 3b9102b200d25bf1164b15675db65db567d26b7b (patch) | |
tree | 445aaef220b399a3d88204fec130cbd270334990 /app/models/blob.rb | |
parent | cc0c61155561e5baa1b28319ceb6633858a7d9f8 (diff) | |
parent | 1bc1c2d0b2cc5c4c1de5ebdf4229edf6d13d6636 (diff) | |
download | gitlab-ce-list-multiple-clusters.tar.gz |
Merge branch 'multiple-clusters-single-list' into 'list-multiple-clusters'list-multiple-clusters
Use single list for multiple clusters
See merge request gitlab-org/gitlab-ce!15669
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r-- | app/models/blob.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index ad0bc2e2ead..29e762724e3 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -76,12 +76,24 @@ class Blob < SimpleDelegator new(blob, project) 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 + end + end + end + def initialize(blob, project = nil) @project = project super(blob) end + def inspect + "#<#{self.class.name} oid:#{id[0..8]} commit:#{commit_id[0..8]} path:#{path}>" + end + # Returns the data of the blob. # # If the blob is a text based blob the content is converted to UTF-8 and any @@ -95,7 +107,10 @@ class Blob < SimpleDelegator end def load_all_data! - super(project.repository) if project + # Endpoint needed: gitlab-org/gitaly#756 + Gitlab::GitalyClient.allow_n_plus_1_calls do + super(project.repository) if project + end end def no_highlighting? |