diff options
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/ci/metadatable.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/ci/partitionable.rb | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/app/models/concerns/ci/metadatable.rb b/app/models/concerns/ci/metadatable.rb index b785e39523d..5dcae7d594d 100644 --- a/app/models/concerns/ci/metadatable.rb +++ b/app/models/concerns/ci/metadatable.rb @@ -10,8 +10,10 @@ module Ci included do has_one :metadata, + ->(build) { where(partition_id: build.partition_id) }, class_name: 'Ci::BuildMetadata', foreign_key: :build_id, + partition_foreign_key: :partition_id, inverse_of: :build, autosave: true diff --git a/app/models/concerns/ci/partitionable.rb b/app/models/concerns/ci/partitionable.rb index aaf07bfee3a..447603c1635 100644 --- a/app/models/concerns/ci/partitionable.rb +++ b/app/models/concerns/ci/partitionable.rb @@ -61,6 +61,10 @@ module Ci before_validation :set_partition_id, on: :create validates :partition_id, presence: true + scope :in_partition, ->(id) do + where(partition_id: (id.respond_to?(:partition_id) ? id.partition_id : id)) + end + def set_partition_id return if partition_id_changed? && partition_id.present? return unless partition_scope_value |