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