diff options
-rw-r--r-- | app/models/project.rb | 12 | ||||
-rw-r--r-- | changelogs/unreleased/optimise-pipelines-json.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 6 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 1 | ||||
-rw-r--r-- | spec/services/ci/process_pipeline_service_spec.rb | 3 |
5 files changed, 9 insertions, 17 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 4da0e016756..112209fef30 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -168,6 +168,8 @@ class Project < ActiveRecord::Base has_many :environments, dependent: :destroy has_many :deployments, dependent: :destroy + has_many :active_runners, -> { active }, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' + accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature @@ -1096,20 +1098,12 @@ class Project < ActiveRecord::Base @shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none end - def active_runners - @active_runners ||= runners.active - end - def active_shared_runners @active_shared_runners ||= shared_runners.active end def any_runners?(&block) - if active_runners.any?(&block) - return true - end - - active_shared_runners.any?(&block) + active_runners.any?(&block) || active_shared_runners.any?(&block) end def valid_runners_token?(token) diff --git a/changelogs/unreleased/optimise-pipelines-json.yml b/changelogs/unreleased/optimise-pipelines-json.yml new file mode 100644 index 00000000000..948679dcbeb --- /dev/null +++ b/changelogs/unreleased/optimise-pipelines-json.yml @@ -0,0 +1,4 @@ +--- +title: Optimise pipelines.json endpoint +merge_request: +author: diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 5d89511449d..f69288f7d67 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -76,12 +76,6 @@ excluded_attributes: statuses: - :trace - :token - pipelines: - - :pending_builds - - :retryable_builds - - :cancelable_statuses - - :manual_actions - - :artifacts methods: labels: diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 59a2560ca06..a899cfcceb7 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -57,6 +57,7 @@ describe Project, models: true do it { is_expected.to have_many(:builds) } it { is_expected.to have_many(:runner_projects) } it { is_expected.to have_many(:runners) } + it { is_expected.to have_many(:active_runners) } it { is_expected.to have_many(:variables) } it { is_expected.to have_many(:triggers) } it { is_expected.to have_many(:pages_domains) } diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index d7df6c5c22e..245e19822f3 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -463,8 +463,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do end def manual_actions - pipeline.reload - pipeline.manual_actions + pipeline.manual_actions(true) end def create_build(name, **opts) |