Unify NORMALIZED_DATA_COLUMNS for Ci::JobDefinition
Summary
From !202196 (comment 2715276189)
If we introduce another column like interruptible where we extract the value into a column, we would have to update this code. Should we define a SSoT in JobDefinition for columns that are extracted from config?
Something like this:
class Ci::JobDefinition
NORMALIZED_DATA_COLUMNS = %i[interruptible]
def self.fabricate(config:, project_id:, partition_id:)
sanitized_config, checksum = sanitize_and_checksum(config)
current_time = Time.current
attributes = {
project_id: project_id,
partition_id: partition_id,
config: sanitized_config,
checksum: checksum,
created_at: current_time,
updated_at: current_time
}
NORMALIZED_DATA_COLUMNS.each do |column|
attributes[column] = sanitized_config.fetch(column) {
column_defaults[column.to_s]
}
end
new(attributes)
end
end
::Ci::JobDefinition
.select(:id, :partition_id, :project_id, :checksum, *Ci::JobDefinition::NORMALIZED_DATA_COLUMNS)
Edited by Furkan Ayhan