diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-06-11 10:02:13 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-06-11 10:02:13 +0000 |
commit | 49bda3f957c0921451e20ec888ffd24e2e9925ea (patch) | |
tree | e344c2c68dc32d5a1f49497aab320197dda50e07 /lib | |
parent | 9749a25f02f2c0a1d33460bff4c5205328577caa (diff) | |
parent | 522c01972c7f46dbe8a2cd7569784fa255997c91 (diff) | |
download | gitlab-ce-49bda3f957c0921451e20ec888ffd24e2e9925ea.tar.gz |
Merge branch 'add-lfs-blob-ids-to-tree-type' into 'master'
Add LFS blob IDs to GraphQL tree type
See merge request gitlab-org/gitlab-ce!28666
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/graphql/loaders/batch_commit_loader.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/graphql/loaders/batch_commit_loader.rb b/lib/gitlab/graphql/loaders/batch_commit_loader.rb new file mode 100644 index 00000000000..f410c3195f8 --- /dev/null +++ b/lib/gitlab/graphql/loaders/batch_commit_loader.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Graphql + module Loaders + class BatchCommitLoader + def initialize(repository, blob_id) + @repository, @blob_id = repository, blob_id + end + + def find + BatchLoader.for(blob_id).batch(key: repository) do |blob_ids, loader, batch_args| + Gitlab::Git::Blob.batch_lfs_pointers(batch_args[:key], blob_ids).each do |loaded_blob| + loader.call(loaded_blob.id, loaded_blob.lfs_oid) + end + end + end + + private + + attr_reader :repository, :blob_id + end + end + end +end |