summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/concerns/resolves_pipelines.rb
blob: 46d9e174deb5198d433898b492bd5f2d65d99a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

module ResolvesPipelines
  extend ActiveSupport::Concern

  included do
    type [Types::Ci::PipelineType], null: false
    argument :status,
             Types::Ci::PipelineStatusEnum,
             required: false,
             description: "Filter pipelines by their status"
    argument :ref,
             GraphQL::STRING_TYPE,
             required: false,
             description: "Filter pipelines by the ref they are run for"
    argument :sha,
             GraphQL::STRING_TYPE,
             required: false,
             description: "Filter pipelines by the sha of the commit they are run for"
  end

  class_methods do
    def resolver_complexity(args, child_complexity:)
      complexity = super
      complexity += 2 if args[:sha]
      complexity += 2 if args[:ref]

      complexity
    end
  end

  def resolve_pipelines(project, params = {})
    Ci::PipelinesFinder.new(project, context[:current_user], params).execute
  end
end