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

#commit_pathObject


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

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

#detailed_statusObject


178
179
180
# File 'app/graphql/types/ci/pipeline_type.rb', line 178

def detailed_status
  object.detailed_status(current_user)
end

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


194
195
196
197
198
199
200
201
202
203
# File 'app/graphql/types/ci/pipeline_type.rb', line 194

def job(id: nil, name: nil)
  raise ::Gitlab::Graphql::Errors::ArgumentError, 'One of id or name is required' unless id || name

  if id
    id = ::Types::GlobalIDType[::CommitStatus].coerce_isolated_input(id) if id
    pipeline.statuses.id_in(id.model_id)
  else
    pipeline.statuses.by_name(name)
  end.take # rubocop: disable CodeReuse/ActiveRecord
end

#pathObject


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

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

#sha(format: Types::ShaFormatEnum.enum[:long]) ⇒ Object


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

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

  pipeline.sha
end

#userObject


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

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