summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRydkin Maxim <maks.rydkin@gmail.com>2017-03-18 13:04:14 +0300
committerRydkin Maxim <maks.rydkin@gmail.com>2017-04-04 21:11:24 +0300
commitb1dc850ad6037def0ed47ea190cb33ba8493ac27 (patch)
tree056a489b9ece78742dc58b0b3cf549daee4e9dd1 /app
parentc77b1cb0fb8a156faa3f7fa828b6838b7b89d439 (diff)
downloadgitlab-ce-b1dc850ad6037def0ed47ea190cb33ba8493ac27.tar.gz
move `auto_cancelable_pipelines` method to `create_pipeline_service.rb`
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb8
-rw-r--r--app/services/ci/create_pipeline_service.rb11
2 files changed, 9 insertions, 10 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 0ac12d9c3dc..49dec770096 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -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?
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index cb09973081a..2f5ffddb12e 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -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