Class: Types::Ci::RunnerType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::Ci::RunnerType
show all
- Defined in:
- app/graphql/types/ci/runner_type.rb
Constant Summary
collapse
- JOB_COUNT_LIMIT =
1000
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Instance Method Details
#admin_url ⇒ Object
131
132
133
|
# File 'app/graphql/types/ci/runner_type.rb', line 131
def admin_url
Gitlab::Routing.url_helpers.admin_runner_url(runner) if can_admin_runners?
end
|
#edit_admin_url ⇒ Object
135
136
137
|
# File 'app/graphql/types/ci/runner_type.rb', line 135
def edit_admin_url
Gitlab::Routing.url_helpers.edit_admin_runner_url(runner) if can_admin_runners?
end
|
#ephemeral_authentication_token ⇒ Object
158
159
160
|
# File 'app/graphql/types/ci/runner_type.rb', line 158
def ephemeral_authentication_token
runner.token if runner.registration_available?
end
|
#ephemeral_register_url ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'app/graphql/types/ci/runner_type.rb', line 139
def ephemeral_register_url
return unless context[:current_user]&.can?(:read_ephemeral_token, runner) && runner.registration_available?
case runner.runner_type
when 'instance_type'
Gitlab::Routing.url_helpers.register_admin_runner_url(runner)
when 'group_type'
Gitlab::Routing.url_helpers.register_group_runner_url(runner.groups[0], runner)
when 'project_type'
Gitlab::Routing.url_helpers.register_project_runner_url(runner.projects[0], runner)
end
end
|
#job_execution_status ⇒ Object
189
190
191
192
193
194
195
196
197
|
# File 'app/graphql/types/ci/runner_type.rb', line 189
def job_execution_status
BatchLoader::GraphQL.for(runner.id).batch(key: :running_builds_exist) do |runner_ids, loader|
statuses = ::Ci::Runner.id_in(runner_ids).with_running_builds.index_by(&:id)
runner_ids.each do |runner_id|
loader.call(runner_id, statuses[runner_id] ? :running : :idle)
end
end
end
|
#maintenance_note_html_resolver ⇒ Object
127
128
129
|
# File 'app/graphql/types/ci/runner_type.rb', line 127
def maintenance_note_html_resolver
::MarkupHelper.markdown(object.maintenance_note, context.to_h.dup)
end
|
#managers ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
|
# File 'app/graphql/types/ci/runner_type.rb', line 177
def managers
BatchLoader::GraphQL.for(runner.id).batch(key: :runner_managers) do |runner_ids, loader|
runner_managers_by_runner_id =
::Ci::RunnerManager.for_runner(runner_ids).order_id_desc.group_by(&:runner_id)
runner_ids.each do |runner_id|
runner_managers = Array.wrap(runner_managers_by_runner_id[runner_id])
loader.call(runner_id, runner_managers)
end
end
end
|
#project_count ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'app/graphql/types/ci/runner_type.rb', line 162
def project_count
BatchLoader::GraphQL.for(runner.id).batch(key: :runner_project_count) do |ids, loader, args|
counts = ::Ci::Runner.project_type
.select(:id, 'COUNT(ci_runner_projects.id) as count')
.left_outer_joins(:runner_projects)
.id_in(ids)
.group(:id) .index_by(&:id)
ids.each do |id|
loader.call(id, counts[id]&.count)
end
end
end
|
#register_admin_url ⇒ Object
152
153
154
155
156
|
# File 'app/graphql/types/ci/runner_type.rb', line 152
def register_admin_url
return unless can_admin_runners? && runner.registration_available?
Gitlab::Routing.url_helpers.register_admin_runner_url(runner)
end
|