Commit 346a7c69 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add after_stage scope to commit status class

parent 3063ab45
......@@ -234,9 +234,7 @@ module Ci
end
def mark_as_processable_after_stage(stage_idx)
builds.skipped
.where('stage_idx > ?', stage_idx)
.find_each(&:process)
builds.skipped.after_stage(stage_idx).find_each(&:process)
end
def latest?
......
......@@ -23,9 +23,6 @@ class CommitStatus < ActiveRecord::Base
where(id: max_id.group(:name, :commit_id))
end
scope :retried, -> { where.not(id: latest) }
scope :ordered, -> { order(:name) }
scope :failed_but_allowed, -> do
where(allow_failure: true, status: [:failed, :canceled])
end
......@@ -36,8 +33,11 @@ class CommitStatus < ActiveRecord::Base
false, all_state_names - [:failed, :canceled])
end
scope :retried, -> { where.not(id: latest) }
scope :ordered, -> { order(:name) }
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
state_machine :status do
event :enqueue do
......
......@@ -11,13 +11,18 @@ module Ci
# Reprocess builds in subsequent stages
#
pipeline.builds
.where('stage_idx > ?', resume_stage.index)
.after_stage(resume_stage.index)
.failed_or_canceled.find_each do |build|
Ci::RetryBuildService
.new(project, current_user)
.reprocess(build)
end
##
# Mark skipped builds as processable again
#
pipeline.mark_as_processable_after_stage(resume_stage.index)
##
# Retry builds in the first unsuccessful stage
#
......@@ -26,11 +31,6 @@ module Ci
.new(project, current_user)
.retry(build)
end
##
# Mark skipped builds as processable again
#
pipeline.mark_as_processable_after_stage(resume_stage.index)
end
private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment