diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-14 19:08:48 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 08:54:33 +0200 |
commit | 9c6c5c79f8d3a555ded0539e06a922bc058d5c20 (patch) | |
tree | 2eaeef2a09d905bf1c4b695014bde5c75c7a0ab0 /app/workers | |
parent | cb8654e85650ba6107031cc978d882f4b2f272cf (diff) | |
download | gitlab-ce-9c6c5c79f8d3a555ded0539e06a922bc058d5c20.tar.gz |
Add Pipeline metrics worker
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/pipeline_metrics_worker.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/workers/pipeline_metrics_worker.rb b/app/workers/pipeline_metrics_worker.rb new file mode 100644 index 00000000000..3d1cd770515 --- /dev/null +++ b/app/workers/pipeline_metrics_worker.rb @@ -0,0 +1,15 @@ +class PipelineMetricsWorker + include Sidekiq::Worker + + sidekiq_options queue: :default + + def perform(pipeline_id) + Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| + merge_requests = pipeline.merge_requests.map(&:id) + + metrics = MergeRequest::Metrics.where(merge_request_id: merge_requests) + metrics.update_all(latest_build_started_at: pipeline.started_at) if pipeline.active? + metrics.update_all(latest_build_finished_at: pipeline.finished_at) if pipeline.success? + end + end +end |