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.'
|
|
|
|
|
|
|
|
def resolve(statuses: nil, security_report_types: [])
|
|
|
|
jobs = init_collection(security_report_types)
|
|
|
|
jobs = jobs.with_status(statuses) if statuses.present?
|
|
|
|
|
|
|
|
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
|