diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-09-18 15:36:03 +0900 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-10-02 17:02:11 +0200 |
commit | e265fc3e28dbfe53d96646588a1587d5626e92de (patch) | |
tree | 49e65514b98037ad831c03ba81920d6840261553 /app/models | |
parent | a5d296e9be7cc48ddc75d04b117ae62bae7c9f5b (diff) | |
download | gitlab-ce-e265fc3e28dbfe53d96646588a1587d5626e92de.tar.gz |
Rename delayed to scheduled
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index be4a6c553e1..6ea574ed8ec 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -186,9 +186,8 @@ module Ci end after_transition any => [:manual] do |build| - puts "#{self.class.name} - #{__callee__}: 1" build.run_after_commit do - build.schedule_delayed_execution + build.schedule end end @@ -237,22 +236,30 @@ module Ci action? && (manual? || retryable?) end - def delayed? + def schedulable? manual? && options[:start_in].present? end - def execute_at - ChronicDuration.parse(options[:start_in])&.seconds&.from_now + def scheduled? + build.build_schedule.exist? end - def schedule_delayed_execution - return unless delayed? + def schedule + return unless schedulable? create_build_schedule!(execute_at: execute_at) end + def unschedule + build&.build_schedule&.delete + end + + def execute_at + ChronicDuration.parse(options[:start_in])&.seconds&.from_now + end + def action? - self.when == 'manual' || self.when == 'delayed' + %w[manual delayed].include?(self.when) end # rubocop: disable CodeReuse/ServiceClass |