Class: Types::Ci::PipelineType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/ci/pipeline_type.rb

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#commitObject



181
182
183
# File 'app/graphql/types/ci/pipeline_type.rb', line 181

def commit
  BatchLoader::GraphQL.wrap(object.commit)
end

#commit_pathObject



193
194
195
# File 'app/graphql/types/ci/pipeline_type.rb', line 193

def commit_path
  ::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end

#detailed_statusObject



185
186
187
# File 'app/graphql/types/ci/pipeline_type.rb', line 185

def detailed_status
  object.detailed_status(current_user)
end

#job(id: nil, name: nil) ⇒ Object



201
202
203
204
205
206
207
208
209
# File 'app/graphql/types/ci/pipeline_type.rb', line 201

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 # rubocop: disable CodeReuse/ActiveRecord
end

#pathObject



197
198
199
# File 'app/graphql/types/ci/pipeline_type.rb', line 197

def path
  ::Gitlab::Routing.url_helpers.project_pipeline_path(object.project, object)
end

#sha(format: ) ⇒ Object



211
212
213
214
215
# File 'app/graphql/types/ci/pipeline_type.rb', line 211

def sha(format: Types::ShaFormatEnum.enum[:long])
  return pipeline.short_sha if format == Types::ShaFormatEnum.enum[:short]

  pipeline.sha
end

#userObject



189
190
191
# File 'app/graphql/types/ci/pipeline_type.rb', line 189

def user
  Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
end