diff options
author | Phil Hughes <me@iamphill.com> | 2019-06-28 10:30:29 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-28 10:30:29 +0300 |
commit | d78f7ceac94abe0e8318c6472fc5f7967325a74f (patch) | |
tree | 831839462f28797c52b8f2452ce3c659c1874b9a /lib/gitlab/graphql | |
parent | 80735a2d4b3615e5bd94ea6032b304b58dd2c357 (diff) |
Added commit type to tree GraphQL type
Diffstat (limited to 'lib/gitlab/graphql')
-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 |