Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-04-21 18:39:19 +0300
committerToon Claes <toon@gitlab.com>2017-04-24 11:23:41 +0300
commit14642e3c28ae40d2ecf409c327e29e6c3add63fa (patch)
tree890a3e495659f9f228d680bf5a9fdc12be2a83aa /app/workers
parentc623c41c2f917e0773a6e3f0b6c78b027ca846f7 (diff)
Refactor ExpirePipelineCacheWorker#perform
Make it gracefully handle unexisting pipelines and refactor iterating all the merge request paths.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/expire_pipeline_cache_worker.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
index 0210d459048..603e2f1aaea 100644
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ b/app/workers/expire_pipeline_cache_worker.rb
@@ -3,14 +3,18 @@ class ExpirePipelineCacheWorker
include PipelineQueue
def perform(pipeline_id)
- pipeline = Ci::Pipeline.find(pipeline_id)
+ pipeline = Ci::Pipeline.find_by(id: pipeline_id)
+ return unless pipeline
+
project = pipeline.project
store = Gitlab::EtagCaching::Store.new
store.touch(project_pipelines_path(project))
store.touch(commit_pipelines_path(project, pipeline.commit)) if pipeline.commit
store.touch(new_merge_request_pipelines_path(project))
- merge_requests_pipelines_paths(project, pipeline).each { |path| store.touch(path) }
+ each_pipelines_merge_request_path(project, pipeline) do |path|
+ store.touch(path)
+ end
Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline)
end
@@ -39,13 +43,15 @@ class ExpirePipelineCacheWorker
format: :json)
end
- def merge_requests_pipelines_paths(project, pipeline)
- pipeline.all_merge_requests.collect do |merge_request|
- Gitlab::Routing.url_helpers.pipelines_namespace_project_merge_request_path(
+ def each_pipelines_merge_request_path(project, pipeline)
+ pipeline.all_merge_requests.each do |merge_request|
+ path = Gitlab::Routing.url_helpers.pipelines_namespace_project_merge_request_path(
project.namespace,
project,
merge_request,
format: :json)
+
+ yield(path)
end
end
end