Class: Types::Ci::PipelineType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::Ci::PipelineType
show all
- Defined in:
- app/graphql/types/ci/pipeline_type.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Class Method Details
.authorization_scopes ⇒ Object
15
16
17
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 15
def self.authorization_scopes
super + [:ai_workflows]
end
|
Instance Method Details
#commit ⇒ Object
236
237
238
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 236
def commit
BatchLoader::GraphQL.wrap(object.commit)
end
|
#commit_path ⇒ Object
259
260
261
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 259
def commit_path
::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end
|
#detailed_status ⇒ Object
251
252
253
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 251
def detailed_status
object.detailed_status(current_user)
end
|
#error_messages ⇒ Object
240
241
242
243
244
245
246
247
248
249
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 240
def error_messages
BatchLoader::GraphQL.for(object).batch do |pipelines, loader|
messages = ::Ci::PipelineMessage.where(pipeline: pipelines, severity: :error)
pipelines.each do |pipeline|
loader.call(pipeline, messages.select { |m| m.pipeline_id == pipeline.id })
end
end
end
|
#failed_jobs_count ⇒ Object
299
300
301
302
303
304
305
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 299
def failed_jobs_count
BatchLoader::GraphQL.for(object).batch do |pipelines, loader|
pipelines.each do |pipeline|
loader.call(pipeline, pipeline.limited_failed_jobs.size)
end
end
end
|
#has_manual_actions? ⇒ Boolean
291
292
293
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 291
def has_manual_actions?
object.association(:manual_actions).loaded? ? object.manual_actions.any? : object.manual_actions.exists?
end
|
#has_scheduled_actions? ⇒ Boolean
295
296
297
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 295
def has_scheduled_actions?
object.association(:scheduled_actions).loaded? ? object.scheduled_actions.any? : object.scheduled_actions.exists?
end
|
#job(id: nil, name: nil) ⇒ Object
275
276
277
278
279
280
281
282
283
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 275
def job(id: nil, name: nil)
raise ::Gitlab::Graphql::Errors::ArgumentError, 'One of id or name is required' unless id || name
if id
pipeline.statuses.id_in(id.model_id)
else
pipeline.latest_statuses.by_name(name)
end.take
end
|
#sha(format: ) ⇒ Object
285
286
287
288
289
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 285
def sha(format: Types::ShaFormatEnum.enum[:long])
return pipeline.short_sha if format == Types::ShaFormatEnum.enum[:short]
pipeline.sha
end
|
#user ⇒ Object
255
256
257
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 255
def user
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
end
|
#warning_messages ⇒ Object
263
264
265
266
267
268
269
270
271
272
273
|
# File 'app/graphql/types/ci/pipeline_type.rb', line 263
def warning_messages
BatchLoader::GraphQL.for(object).batch do |pipelines, loader|
messages = ::Ci::PipelineMessage.where(pipeline: pipelines, severity: :warning)
pipelines.each do |pipeline|
loader.call(pipeline, messages.select { |m| m.pipeline_id == pipeline.id })
end
end
end
|