Commit b1dc850a authored by Rydkin Maxim's avatar Rydkin Maxim

move `auto_cancelable_pipelines` method to `create_pipeline_service.rb`

parent c77b1cb0
......@@ -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
......
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