Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/ci')
-rw-r--r--app/graphql/types/ci/detailed_status_type.rb2
-rw-r--r--app/graphql/types/ci/job_type.rb2
-rw-r--r--app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb19
-rw-r--r--app/graphql/types/ci/pipeline_type.rb3
-rw-r--r--app/graphql/types/ci/runner_type.rb29
-rw-r--r--app/graphql/types/ci/runner_web_url_edge.rb11
-rw-r--r--app/graphql/types/ci/status_action_type.rb3
7 files changed, 52 insertions, 17 deletions
diff --git a/app/graphql/types/ci/detailed_status_type.rb b/app/graphql/types/ci/detailed_status_type.rb
index e3413551a3f..3fab040cc0b 100644
--- a/app/graphql/types/ci/detailed_status_type.rb
+++ b/app/graphql/types/ci/detailed_status_type.rb
@@ -33,7 +33,7 @@ module Types
method: :status_tooltip
def id(parent:)
- "#{object.id}-#{parent.object.object.id}"
+ "#{object.id}-#{parent.id}"
end
def action
diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb
index f25fc56a588..b20a671179b 100644
--- a/app/graphql/types/ci/job_type.rb
+++ b/app/graphql/types/ci/job_type.rb
@@ -7,7 +7,7 @@ module Types
class JobType < BaseObject
graphql_name 'CiJob'
- connection_type_class(Types::CountableConnectionType)
+ connection_type_class(Types::LimitedCountableConnectionType)
expose_permissions Types::PermissionTypes::Ci::Job
diff --git a/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb b/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb
new file mode 100644
index 00000000000..a1236b8f2c1
--- /dev/null
+++ b/app/graphql/types/ci/pipeline_merge_request_event_type_enum.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ module Ci
+ class PipelineMergeRequestEventTypeEnum < BaseEnum
+ graphql_name 'PipelineMergeRequestEventType'
+ description 'Event type of the pipeline associated with a merge request'
+
+ value 'MERGED_RESULT',
+ 'Pipeline run on the changes from the source branch combined with the target branch.',
+ value: :merged_result
+ value 'DETACHED',
+ 'Pipeline run on the changes in the merge request source branch.',
+ value: :detached
+ end
+ end
+end
+
+Types::Ci::PipelineMergeRequestEventTypeEnum.prepend_mod
diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb
index 81afc7f0f42..60418fec6c5 100644
--- a/app/graphql/types/ci/pipeline_type.rb
+++ b/app/graphql/types/ci/pipeline_type.rb
@@ -175,6 +175,9 @@ module Types
field :warning_messages, [Types::Ci::PipelineMessageType], null: true,
description: 'Pipeline warning messages.'
+ field :merge_request_event_type, Types::Ci::PipelineMergeRequestEventTypeEnum, null: true,
+ description: "Event type of the pipeline associated with a merge request."
+
def detailed_status
object.detailed_status(current_user)
end
diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb
index 6f957d2511f..949e216a982 100644
--- a/app/graphql/types/ci/runner_type.rb
+++ b/app/graphql/types/ci/runner_type.rb
@@ -85,6 +85,15 @@ module Types
method: :token_expires_at
field :version, GraphQL::Types::String, null: true,
description: 'Version of the runner.'
+ field :owner_project, ::Types::ProjectType, null: true,
+ description: 'Project that owns the runner. For project runners only.',
+ resolver: ::Resolvers::Ci::RunnerOwnerProjectResolver
+
+ markdown_field :maintenance_note_html, null: true
+
+ def maintenance_note_html_resolver
+ ::MarkupHelper.markdown(object.maintenance_note, context.to_h.dup)
+ end
def job_count
# We limit to 1 above the JOB_COUNT_LIMIT to indicate that more items exist after JOB_COUNT_LIMIT
@@ -136,16 +145,22 @@ module Types
# rubocop: disable CodeReuse/ActiveRecord
def batched_owners(runner_assoc_type, assoc_type, key, column_name)
- BatchLoader::GraphQL.for(runner.id).batch(key: key) do |runner_ids, loader, args|
- runner_and_owner_ids = runner_assoc_type.where(runner_id: runner_ids).pluck(:runner_id, column_name)
-
- owner_ids_by_runner_id = runner_and_owner_ids.group_by(&:first).transform_values { |v| v.pluck(1) }
- owner_ids = runner_and_owner_ids.pluck(1).uniq
-
+ BatchLoader::GraphQL.for(runner.id).batch(key: key) do |runner_ids, loader|
+ plucked_runner_and_owner_ids = runner_assoc_type
+ .select(:runner_id, column_name)
+ .where(runner_id: runner_ids)
+ .pluck(:runner_id, column_name)
+ # In plucked_runner_and_owner_ids, first() represents the runner ID, and second() the owner ID,
+ # so let's group the owner IDs by runner ID
+ runner_owner_ids_by_runner_id = plucked_runner_and_owner_ids
+ .group_by(&:first)
+ .transform_values { |runner_and_owner_id| runner_and_owner_id.map(&:second) }
+
+ owner_ids = runner_owner_ids_by_runner_id.values.flatten.uniq
owners = assoc_type.where(id: owner_ids).index_by(&:id)
runner_ids.each do |runner_id|
- loader.call(runner_id, owner_ids_by_runner_id[runner_id]&.map { |owner_id| owners[owner_id] } || [])
+ loader.call(runner_id, runner_owner_ids_by_runner_id[runner_id]&.map { |owner_id| owners[owner_id] } || [])
end
end
end
diff --git a/app/graphql/types/ci/runner_web_url_edge.rb b/app/graphql/types/ci/runner_web_url_edge.rb
index 035d75c22c6..7dfcd1f3510 100644
--- a/app/graphql/types/ci/runner_web_url_edge.rb
+++ b/app/graphql/types/ci/runner_web_url_edge.rb
@@ -4,8 +4,6 @@ module Types
module Ci
# rubocop: disable Graphql/AuthorizeTypes
class RunnerWebUrlEdge < ::Types::BaseEdge
- include FindClosest
-
field :edit_url, GraphQL::Types::String, null: true,
description: 'Web URL of the runner edit page. The value depends on where you put this field in the query. You can use it for projects or groups.',
extras: [:parent]
@@ -19,19 +17,18 @@ module Types
@runner = node.node
end
+ # here parent is a Keyset::Connection
def edit_url(parent:)
- runner_url(parent: parent, url_type: :edit_url)
+ runner_url(owner: parent.parent, url_type: :edit_url)
end
def web_url(parent:)
- runner_url(parent: parent, url_type: :default)
+ runner_url(owner: parent.parent, url_type: :default)
end
private
- def runner_url(parent:, url_type: :default)
- owner = closest_parent([::Types::ProjectType, ::Types::GroupType], parent)
-
+ def runner_url(owner:, url_type: :default)
# Only ::Group is supported at the moment, future iterations will include ::Project.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/16338
case owner
diff --git a/app/graphql/types/ci/status_action_type.rb b/app/graphql/types/ci/status_action_type.rb
index 26ca3c1438a..c0f61cf49f2 100644
--- a/app/graphql/types/ci/status_action_type.rb
+++ b/app/graphql/types/ci/status_action_type.rb
@@ -21,7 +21,8 @@ module Types
description: 'Title for the action, for example: Retry.'
def id(parent:)
- "#{parent.parent.object.object.class.name}-#{parent.object.object.id}"
+ # parent is a SimpleDelegator
+ "#{parent.subject.class.name}-#{parent.id}"
end
def action_method