Class: Types::Ci::JobType
Overview
rubocop: disable Graphql/AuthorizeTypes The permission is presented through `StageType` that has its own authorization
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user
#present, #unpresented
Instance Method Details
#artifacts ⇒ Object
114
115
116
117
118
|
# File 'app/graphql/types/ci/job_type.rb', line 114
def artifacts
if object.is_a?(::Ci::Build)
object.job_artifacts
end
end
|
#commit_path ⇒ Object
168
169
170
|
# File 'app/graphql/types/ci/job_type.rb', line 168
def commit_path
::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end
|
#coverage ⇒ Object
180
181
182
|
# File 'app/graphql/types/ci/job_type.rb', line 180
def coverage
object&.coverage
end
|
#detailed_status ⇒ Object
110
111
112
|
# File 'app/graphql/types/ci/job_type.rb', line 110
def detailed_status
object.detailed_status(context[:current_user])
end
|
#downstream_pipeline ⇒ Object
102
103
104
|
# File 'app/graphql/types/ci/job_type.rb', line 102
def downstream_pipeline
object.downstream_pipeline if object.respond_to?(:downstream_pipeline)
end
|
#id ⇒ Object
This class is a secret union! TODO: turn this into an actual union, so that fields can be referenced safely!
160
161
162
163
164
165
166
|
# File 'app/graphql/types/ci/job_type.rb', line 160
def id
return unless object.id.present?
model_name = object.type || ::CommitStatus.name
id = object.id
Gitlab::GlobalId.build(model_name: model_name, id: id)
end
|
#kind ⇒ Object
92
93
94
95
96
|
# File 'app/graphql/types/ci/job_type.rb', line 92
def kind
return ::Ci::Build unless [::Ci::Build, ::Ci::Bridge].include?(object.class)
object.class
end
|
#manual_job ⇒ Object
184
185
186
|
# File 'app/graphql/types/ci/job_type.rb', line 184
def manual_job
object.try(:action?)
end
|
#previous_stage_jobs ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'app/graphql/types/ci/job_type.rb', line 130
def previous_stage_jobs
BatchLoader::GraphQL.for([object.pipeline, object.stage_idx - 1]).batch(default_value: []) do |tuples, loader|
tuples.group_by(&:first).each do |pipeline, keys|
positions = keys.map(&:second)
stages = pipeline.stages.by_position(positions)
stages.each do |stage|
loader.call([pipeline, stage.position], stage.latest_statuses)
end
end
end
end
|
#previous_stage_jobs_or_needs ⇒ Object
120
121
122
123
124
125
126
127
128
|
# File 'app/graphql/types/ci/job_type.rb', line 120
def previous_stage_jobs_or_needs
if object.scheduling_type == 'stage'
Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs|
jobs
end
else
object.needs
end
end
|
#ref_name ⇒ Object
172
173
174
|
# File 'app/graphql/types/ci/job_type.rb', line 172
def ref_name
object&.ref
end
|
#ref_path ⇒ Object
176
177
178
|
# File 'app/graphql/types/ci/job_type.rb', line 176
def ref_path
::Gitlab::Routing.url_helpers.project_commits_path(object.project, ref_name)
end
|
#stage ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'app/graphql/types/ci/job_type.rb', line 144
def stage
::Gitlab::Graphql::Lazy.with_value(pipeline) do |pl|
BatchLoader::GraphQL.for([pl, object.stage]).batch do |ids, loader|
by_pipeline = ids
.group_by(&:first)
.transform_values { |grp| grp.map(&:second) }
by_pipeline.each do |p, names|
p.stages.by_name(names).each { |s| loader.call([p, s.name], s) }
end
end
end
end
|
106
107
108
|
# File 'app/graphql/types/ci/job_type.rb', line 106
def tags
object.tags.map(&:name) if object.is_a?(::Ci::Build)
end
|
#triggered ⇒ Object
188
189
190
|
# File 'app/graphql/types/ci/job_type.rb', line 188
def triggered
object.try(:trigger_request)
end
|