Commit 7d4767fb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extract updating pipeline status to async worker

parent 57863874
...@@ -78,10 +78,14 @@ class CommitStatus < ActiveRecord::Base ...@@ -78,10 +78,14 @@ class CommitStatus < ActiveRecord::Base
end end
after_transition do |commit_status, transition| after_transition do |commit_status, transition|
if commit_status.pipeline && !transition.loopback? return if transition.loopback?
ProcessPipelineWorker.perform_async(
commit_status.pipeline.id, process: commit_status.complete? commit_status.pipeline.try(:id).try do |pipeline_id|
) if commit_status.complete?
ProcessPipelineWorker.perform_async(pipeline_id)
end
UpdatePipelineWorker.perform_async(pipeline_id)
end end
true true
......
...@@ -3,15 +3,10 @@ class ProcessPipelineWorker ...@@ -3,15 +3,10 @@ class ProcessPipelineWorker
sidekiq_options queue: :default sidekiq_options queue: :default
def perform(pipeline_id, params) def perform(pipeline_id)
begin pipeline = Ci::Pipeline.find_by(id: pipeline_id)
pipeline = Ci::Pipeline.find(pipeline_id) return unless pipeline
rescue ActiveRecord::RecordNotFound
return
end
pipeline.process! if params['process']
pipeline.update_status pipeline.process!
end end
end end
class UpdatePipelineWorker
include Sidekiq::Worker
sidekiq_options queue: :default
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline
pipeline.update_status
end
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