summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-05-21 00:07:36 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-05-22 22:07:11 +0200
commitda0c543e289ffc2be0b91b3257bab6f1d0d5dac3 (patch)
treebb38c9f317e237d1a4b242b6a0e74d1bdc4349ac
parent33961ee418e861a021d7f70bdb1540de9d159b95 (diff)
downloadgitlab-ce-da0c543e289ffc2be0b91b3257bab6f1d0d5dac3.tar.gz
Add MISSING e-tag refresh of resource for Job, and Pipeline Graph
-rw-r--r--app/models/commit_status.rb1
-rw-r--r--app/workers/expire_job_cache_worker.rb37
-rw-r--r--app/workers/expire_pipeline_cache_worker.rb9
3 files changed, 47 insertions, 0 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index ffafc678968..957f707a733 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -89,6 +89,7 @@ class CommitStatus < ActiveRecord::Base
else
PipelineUpdateWorker.perform_async(pipeline.id)
end
+ ExpireJobCacheWorker.perform_async(pipeline.id, commit_status.id)
end
end
end
diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb
new file mode 100644
index 00000000000..e3930ee9d41
--- /dev/null
+++ b/app/workers/expire_job_cache_worker.rb
@@ -0,0 +1,37 @@
+class ExpireJobCacheWorker
+ include Sidekiq::Worker
+ include BuildQueue
+
+ def perform(pipeline_id, job_id)
+ job = CommitStatus.joins(:pipeline, :project).find_by(id: job)
+ return unless job
+
+ pipeline = job.pipeline
+ project = job.project
+
+ store.touch(project_pipeline_path(project, pipeline))
+ store.touch(project_job_path(project, job))
+ end
+
+ private
+
+ def project_pipeline_path(project, pipeline)
+ Gitlab::Routing.url_helpers.namespace_project_pipeline_path(
+ project.namespace,
+ project,
+ pipeline,
+ format: :json)
+ end
+
+ def project_job_path(project, job)
+ Gitlab::Routing.url_helpers.namespace_project_build_path(
+ project.namespace,
+ project,
+ job.id,
+ format: :json)
+ end
+
+ def store
+ @store ||= Gitlab::EtagCaching::Store.new
+ end
+end
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
index 603e2f1aaea..d760f5b140f 100644
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ b/app/workers/expire_pipeline_cache_worker.rb
@@ -10,6 +10,7 @@ class ExpirePipelineCacheWorker
store = Gitlab::EtagCaching::Store.new
store.touch(project_pipelines_path(project))
+ store.touch(project_pipeline_path(project, pipeline))
store.touch(commit_pipelines_path(project, pipeline.commit)) if pipeline.commit
store.touch(new_merge_request_pipelines_path(project))
each_pipelines_merge_request_path(project, pipeline) do |path|
@@ -28,6 +29,14 @@ class ExpirePipelineCacheWorker
format: :json)
end
+ def project_pipeline_path(project, pipeline)
+ Gitlab::Routing.url_helpers.namespace_project_pipeline_path(
+ project.namespace,
+ project,
+ pipeline,
+ format: :json)
+ end
+
def commit_pipelines_path(project, commit)
Gitlab::Routing.url_helpers.pipelines_namespace_project_commit_path(
project.namespace,