debian-mirror-gitlab/app/graphql/resolvers/ci/jobs_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.3 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Resolvers
module Ci
class JobsResolver < BaseResolver
alias_method :pipeline, :object
2021-02-22 17:27:13 +05:30
type ::Types::Ci::JobType.connection_type, null: true
2021-01-29 00:20:46 +05:30
argument :security_report_types, [Types::Security::ReportTypeEnum],
required: false,
2021-03-08 18:12:59 +05:30
description: 'Filter jobs by the type of security report they produce.'
2021-01-29 00:20:46 +05:30
2021-04-29 21:17:54 +05:30
argument :statuses, [::Types::Ci::JobStatusEnum],
required: false,
description: 'Filter jobs by status.'
2022-08-13 15:12:31 +05:30
argument :retried, ::GraphQL::Types::Boolean,
required: false,
description: 'Filter jobs by retry-status.'
def resolve(statuses: nil, security_report_types: [], retried: nil)
2021-04-29 21:17:54 +05:30
jobs = init_collection(security_report_types)
jobs = jobs.with_status(statuses) if statuses.present?
2022-08-13 15:12:31 +05:30
jobs = jobs.retried if retried
jobs = jobs.latest if retried == false
2021-04-29 21:17:54 +05:30
jobs
end
def init_collection(security_report_types)
2021-01-29 00:20:46 +05:30
if security_report_types.present?
::Security::SecurityJobsFinder.new(
pipeline: pipeline,
job_types: security_report_types
).execute
else
2022-01-26 12:08:38 +05:30
pipeline.statuses_order_id_desc
2021-01-29 00:20:46 +05:30
end
end
end
end
end