debian-mirror-gitlab/app/models/ci/pending_build.rb
2021-09-04 02:52:04 +05:30

18 lines
446 B
Ruby

# frozen_string_literal: true
module Ci
class PendingBuild < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :project
belongs_to :build, class_name: 'Ci::Build'
def self.upsert_from_build!(build)
entry = self.new(build: build, project: build.project, protected: build.protected?)
entry.validate!
self.upsert(entry.attributes.compact, returning: %w[build_id], unique_by: :build_id)
end
end
end