diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-09-25 14:21:41 +0900 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-10-02 17:04:04 +0200 |
commit | 2f03c503fb299a4a821d74f75c31aa1189fcbccb (patch) | |
tree | b90993eaf676ea86abbb401e8364f1fc8ac9d515 /app | |
parent | 422970c93eb0ff445da5c3351cdfd70bb387e57c (diff) | |
download | gitlab-ce-2f03c503fb299a4a821d74f75c31aa1189fcbccb.tar.gz |
Introduce ProceedBuildService
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/presenters/ci/build_presenter.rb | 2 | ||||
-rw-r--r-- | app/services/ci/enqueue_build_service.rb | 8 | ||||
-rw-r--r-- | app/services/ci/proceed_build_service.rb | 15 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 12 |
5 files changed, 19 insertions, 22 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3f2630798f3..6c72bce75e3 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -180,7 +180,7 @@ module Ci end before_transition created: :scheduled do |build| - build.scheduled_at = build.get_scheduled_at + build.scheduled_at = build.options_scheduled_at end after_transition created: :scheduled do |build| @@ -263,7 +263,7 @@ module Ci self.when == 'delayed' && options[:start_in].present? end - def get_scheduled_at + def options_scheduled_at ChronicDuration.parse(options[:start_in])&.seconds&.from_now end diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb index 4005840ce58..33056a809b7 100644 --- a/app/presenters/ci/build_presenter.rb +++ b/app/presenters/ci/build_presenter.rb @@ -36,7 +36,7 @@ module Ci end def execute_in - [0, scheduled_at - Time.now].max + scheduled? && scheduled_at && [0, scheduled_at - Time.now].max end private diff --git a/app/services/ci/enqueue_build_service.rb b/app/services/ci/enqueue_build_service.rb deleted file mode 100644 index 8140651d980..00000000000 --- a/app/services/ci/enqueue_build_service.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true -module Ci - class EnqueueBuildService < BaseService - def execute(build) - build.enqueue - end - end -end diff --git a/app/services/ci/proceed_build_service.rb b/app/services/ci/proceed_build_service.rb new file mode 100644 index 00000000000..c8119c2b468 --- /dev/null +++ b/app/services/ci/proceed_build_service.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Ci + class ProceedBuildService < BaseService + def execute(build) + if build.schedulable? + build.schedule! + elsif build.action? + build.actionize + else + build.enqueue + end + end + end +end diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 0a13da198cd..f122fc8798c 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -37,7 +37,7 @@ module Ci def process_build(build, current_status) if valid_statuses_for_when(build.when).include?(current_status) - proceed_build(build) + Ci::ProceedBuildService.new(project, @user).execute(build) true else build.skip @@ -103,15 +103,5 @@ module Ci .update_all(retried: true) if latest_statuses.any? end # rubocop: enable CodeReuse/ActiveRecord - - def proceed_build(build) - if build.schedulable? - build.schedule! - elsif build.action? - build.actionize - else - Ci::EnqueueBuildService.new(project, @user).execute(build) - end - end end end |