Class: Ci::Processable
Constant Summary
Constants included
from HasStatus
HasStatus::ACTIVE_STATUSES, HasStatus::AVAILABLE_STATUSES, HasStatus::BLOCKED_STATUS, HasStatus::COMPLETED_STATUSES, HasStatus::DEFAULT_STATUS, HasStatus::EXCLUDE_IGNORED_STATUSES, HasStatus::ORDERED_STATUSES, HasStatus::PASSED_WITH_WARNINGS_STATUSES, HasStatus::STARTED_STATUSES, HasStatus::STATUSES_ENUM, HasStatus::UnknownStatusError
Instance Attribute Summary
Attributes included from Importable
#imported, #importing
Class Method Summary
collapse
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
#all_met_to_become_pending?, #any_unmet_prerequisites?, #archived?, #auto_canceled?, #cancelable?, #detailed_status, #duration, #failed_but_allowed?, #group_name, #has_trace?, #importing?, #latest?, locking_enabled?, #locking_enabled?, names, #playable?, #recoverable?, #requires_resource?, #retryable?, #sortable_name, #stuck?, update_as_processed!
#bulk_insert_associations!, bulk_inserts_enabled?, with_bulk_insert
#present
#run_after_commit, #run_after_commit_or_now
Methods included from HasStatus
#active?, #blocked?, #complete?, #started?
at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, where_exists, with_fast_statement_timeout, without_order
Class Method Details
.populate_scheduling_type! ⇒ Object
Old processables may have scheduling_type as nil, so we need to ensure the data exists before using it.
37
38
39
40
41
42
43
44
45
|
# File 'app/models/ci/processable.rb', line 37
def self.populate_scheduling_type!
needs = Ci::BuildNeed.scoped_build.select(1)
where(scheduling_type: nil).update_all(
"scheduling_type = CASE WHEN (EXISTS (#{needs.to_sql}))
THEN #{scheduling_types[:dag]}
ELSE #{scheduling_types[:stage]}
END"
)
end
|
.select_with_aggregated_needs(project) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/ci/processable.rb', line 23
def self.select_with_aggregated_needs(project)
aggregated_needs_names = Ci::BuildNeed
.scoped_build
.select("ARRAY_AGG(name)")
.to_sql
all.select(
'*',
"(#{aggregated_needs_names}) as aggregated_needs_names"
)
end
|
Instance Method Details
#action? ⇒ Boolean
64
65
66
|
# File 'app/models/ci/processable.rb', line 64
def action?
raise NotImplementedError
end
|
#aggregated_needs_names ⇒ Object
56
57
58
|
# File 'app/models/ci/processable.rb', line 56
def aggregated_needs_names
read_attribute(:aggregated_needs_names)
end
|
#all_dependencies ⇒ Object
115
116
117
|
# File 'app/models/ci/processable.rb', line 115
def all_dependencies
dependencies.all
end
|
#dependency_variables ⇒ Object
107
108
109
110
111
112
113
|
# File 'app/models/ci/processable.rb', line 107
def dependency_variables
return [] if all_dependencies.empty?
Gitlab::Ci::Variables::Collection.new.concat(
Ci::JobVariable.where(job: all_dependencies).dotenv_source
)
end
|
#ensure_scheduling_type! ⇒ Object
99
100
101
102
103
104
105
|
# File 'app/models/ci/processable.rb', line 99
def ensure_scheduling_type!
return if scheduling_type
pipeline.ensure_scheduling_type!
reset
end
|
#expanded_environment_name ⇒ Object
72
73
74
|
# File 'app/models/ci/processable.rb', line 72
def expanded_environment_name
raise NotImplementedError
end
|
#find_legacy_scheduling_type ⇒ Object
scheduling_type column of previous builds/bridges have not been populated, so we calculate this value on runtime when we need it.
87
88
89
90
91
|
# File 'app/models/ci/processable.rb', line 87
def find_legacy_scheduling_type
strong_memoize(:find_legacy_scheduling_type) do
needs.exists? ? :dag : :stage
end
end
|
#needs_attributes ⇒ Object
93
94
95
96
97
|
# File 'app/models/ci/processable.rb', line 93
def needs_attributes
strong_memoize(:needs_attributes) do
needs.map { |need| need.attributes.except('id', 'build_id') }
end
end
|
#schedulable? ⇒ Boolean
60
61
62
|
# File 'app/models/ci/processable.rb', line 60
def schedulable?
raise NotImplementedError
end
|
#scheduling_type_dag? ⇒ Boolean
Overriding scheduling_type enum's method for nil `scheduling_type`s
81
82
83
|
# File 'app/models/ci/processable.rb', line 81
def scheduling_type_dag?
scheduling_type.nil? ? find_legacy_scheduling_type == :dag : super
end
|
#scoped_variables_hash ⇒ Object
76
77
78
|
# File 'app/models/ci/processable.rb', line 76
def scoped_variables_hash
raise NotImplementedError
end
|
#when ⇒ Object
68
69
70
|
# File 'app/models/ci/processable.rb', line 68
def when
read_attribute(:when) || 'on_success'
end
|