diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2019-06-28 10:02:57 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-06-28 10:02:57 +0000 |
commit | 2321b337f1487031e2cab8e1a4e778f3aaf8e2da (patch) | |
tree | 09ac0a7fe65e4da93f873e4b8cf02b57cd359791 /lib | |
parent | 1012cfb0b780bc9348a8478a66af2a337a69b0f6 (diff) | |
parent | d78f7ceac94abe0e8318c6472fc5f7967325a74f (diff) | |
download | gitlab-ce-2321b337f1487031e2cab8e1a4e778f3aaf8e2da.tar.gz |
Merge branch 'graphql-tree-last-commit' into 'master'
Added commit type to tree GraphQL type
See merge request gitlab-org/gitlab-ce!29412
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/graphql/loaders/pipeline_for_sha_loader.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/graphql/loaders/pipeline_for_sha_loader.rb b/lib/gitlab/graphql/loaders/pipeline_for_sha_loader.rb new file mode 100644 index 00000000000..81c5cabf451 --- /dev/null +++ b/lib/gitlab/graphql/loaders/pipeline_for_sha_loader.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Graphql + module Loaders + class PipelineForShaLoader + attr_accessor :project, :sha + + def initialize(project, sha) + @project, @sha = project, sha + end + + def find_last + BatchLoader.for(sha).batch(key: project) do |shas, loader, args| + pipelines = args[:key].ci_pipelines.latest_for_shas(shas) + + pipelines.each do |pipeline| + loader.call(pipeline.sha, pipeline) + end + end + end + end + end + end +end |