move auto_cancelable_pipelines
method to create_pipeline_service.rb
This commit is contained in:
parent
c77b1cb0fb
commit
b1dc850ad6
2 changed files with 9 additions and 10 deletions
|
@ -127,14 +127,6 @@ module Ci
|
|||
where.not(duration: nil).sum(:duration)
|
||||
end
|
||||
|
||||
def auto_cancelable_pipelines
|
||||
project.pipelines
|
||||
.where(ref: ref)
|
||||
.where.not(id: id)
|
||||
.where.not(sha: project.repository.sha_from_ref(ref))
|
||||
.created_or_pending
|
||||
end
|
||||
|
||||
def stage(name)
|
||||
stage = Ci::Stage.new(self, name: name)
|
||||
stage unless stage.statuses_count.zero?
|
||||
|
|
|
@ -66,8 +66,7 @@ module Ci
|
|||
end
|
||||
|
||||
def cancel_pending_pipelines
|
||||
Gitlab::OptimisticLocking.retry_lock(
|
||||
pipeline.auto_cancelable_pipelines) do |cancelables|
|
||||
Gitlab::OptimisticLocking.retry_lock(auto_cancelable_pipelines) do |cancelables|
|
||||
cancelables.find_each do |cancelable|
|
||||
cancelable.cancel_running
|
||||
cancelable.update_attributes(auto_canceled_by: pipeline.id)
|
||||
|
@ -75,6 +74,14 @@ module Ci
|
|||
end
|
||||
end
|
||||
|
||||
def auto_cancelable_pipelines
|
||||
project.pipelines
|
||||
.where(ref: pipeline.ref)
|
||||
.where.not(id: pipeline.id)
|
||||
.where.not(sha: project.repository.sha_from_ref(pipeline.ref))
|
||||
.created_or_pending
|
||||
end
|
||||
|
||||
def commit
|
||||
@commit ||= project.commit(origin_sha || origin_ref)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue