summaryrefslogtreecommitdiff
path: root/app/workers/expire_job_cache_worker.rb
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2017-08-18 14:26:11 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2017-08-18 14:26:11 +1100
commit2047991363844b4f17216f94778b432ed198a412 (patch)
tree6b90710c44dae00178ad323d796beb59737f47f1 /app/workers/expire_job_cache_worker.rb
parent7a1c5ba7471b233c994f5b5b313085d0d1292b5d (diff)
parentf3203cbbc25586df622552153cc460d2f79f414e (diff)
downloadgitlab-ce-2047991363844b4f17216f94778b432ed198a412.tar.gz
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'app/workers/expire_job_cache_worker.rb')
-rw-r--r--app/workers/expire_job_cache_worker.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb
new file mode 100644
index 00000000000..e383202260d
--- /dev/null
+++ b/app/workers/expire_job_cache_worker.rb
@@ -0,0 +1,27 @@
+class ExpireJobCacheWorker
+ include Sidekiq::Worker
+ include BuildQueue
+
+ def perform(job_id)
+ job = CommitStatus.joins(:pipeline, :project).find_by(id: job_id)
+ return unless job
+
+ pipeline = job.pipeline
+ project = job.project
+
+ Gitlab::EtagCaching::Store.new.tap do |store|
+ store.touch(project_pipeline_path(project, pipeline))
+ store.touch(project_job_path(project, job))
+ end
+ end
+
+ private
+
+ def project_pipeline_path(project, pipeline)
+ Gitlab::Routing.url_helpers.project_pipeline_path(project, pipeline, format: :json)
+ end
+
+ def project_job_path(project, job)
+ Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json)
+ end
+end