diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-16 21:07:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-16 21:07:32 +0300 |
commit | 6ba7c824e92d68c6ae25f64bda5ab213ad9c9a58 (patch) | |
tree | 72b28f0f5222162a67a1919ff25beff4c2cabc2d /app/models/ci/stage.rb | |
parent | acee9d6fb529ca8fb91b2b07bd49bd207df23c51 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/ci/stage.rb')
-rw-r--r-- | app/models/ci/stage.rb | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 3d2df9a45ef..e413ed8a668 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -21,19 +21,45 @@ module Ci belongs_to :project belongs_to :pipeline - has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id, inverse_of: :ci_stage - has_many :latest_statuses, -> { ordered.latest }, + has_many :statuses, + ->(stage) { in_partition(stage) }, class_name: 'CommitStatus', foreign_key: :stage_id, + partition_foreign_key: :partition_id, inverse_of: :ci_stage - has_many :retried_statuses, -> { ordered.retried }, + has_many :latest_statuses, + ->(stage) { in_partition(stage).ordered.latest }, class_name: 'CommitStatus', foreign_key: :stage_id, + partition_foreign_key: :partition_id, + inverse_of: :ci_stage + has_many :retried_statuses, + ->(stage) { in_partition(stage).ordered.retried }, + class_name: 'CommitStatus', + foreign_key: :stage_id, + partition_foreign_key: :partition_id, + inverse_of: :ci_stage + has_many :processables, + ->(stage) { in_partition(stage) }, + class_name: 'Ci::Processable', + foreign_key: :stage_id, + partition_foreign_key: :partition_id, + inverse_of: :ci_stage + has_many :builds, + ->(stage) { in_partition(stage) }, + foreign_key: :stage_id, + partition_foreign_key: :partition_id, + inverse_of: :ci_stage + has_many :bridges, + ->(stage) { in_partition(stage) }, + foreign_key: :stage_id, + partition_foreign_key: :partition_id, + inverse_of: :ci_stage + has_many :generic_commit_statuses, + ->(stage) { in_partition(stage) }, + foreign_key: :stage_id, + partition_foreign_key: :partition_id, inverse_of: :ci_stage - has_many :processables, class_name: 'Ci::Processable', foreign_key: :stage_id, inverse_of: :ci_stage - has_many :builds, foreign_key: :stage_id, inverse_of: :ci_stage - has_many :bridges, foreign_key: :stage_id, inverse_of: :ci_stage - has_many :generic_commit_statuses, foreign_key: :stage_id, inverse_of: :ci_stage scope :ordered, -> { order(position: :asc) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } @@ -107,6 +133,10 @@ module Ci end end + def self.use_partition_id_filter? + Ci::Pipeline.use_partition_id_filter? + end + def set_status(new_status) retry_optimistic_lock(self, name: 'ci_stage_set_status') do case new_status |