summaryrefslogtreecommitdiff
path: root/app/models/ci/processable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/processable.rb')
-rw-r--r--app/models/ci/processable.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/ci/processable.rb b/app/models/ci/processable.rb
index 6c4b271cd2c..95fb75688a9 100644
--- a/app/models/ci/processable.rb
+++ b/app/models/ci/processable.rb
@@ -2,10 +2,14 @@
module Ci
class Processable < ::CommitStatus
+ include Gitlab::Utils::StrongMemoize
+
has_many :needs, class_name: 'Ci::BuildNeed', foreign_key: :build_id, inverse_of: :build
accepts_nested_attributes_for :needs
+ enum scheduling_type: { stage: 0, dag: 1 }, _prefix: true
+
scope :preload_needs, -> { preload(:needs) }
def self.select_with_aggregated_needs(project)
@@ -23,6 +27,7 @@ module Ci
end
validates :type, presence: true
+ validates :scheduling_type, presence: true, on: :create, if: :validate_scheduling_type?
def aggregated_needs_names
read_attribute(:aggregated_needs_names)
@@ -47,5 +52,19 @@ module Ci
def scoped_variables_hash
raise NotImplementedError
end
+
+ # scheduling_type column of previous builds/bridges have not been populated,
+ # so we calculate this value on runtime when we need it.
+ def find_legacy_scheduling_type
+ strong_memoize(:find_legacy_scheduling_type) do
+ needs.exists? ? :dag : :stage
+ end
+ end
+
+ private
+
+ def validate_scheduling_type?
+ !importing? && Feature.enabled?(:validate_scheduling_type_of_processables, project)
+ end
end
end