2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-20 18:07:36 -04:00
|
|
|
class ExpireJobCacheWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2017-08-21 08:16:51 -04:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 11:16:50 -05:00
|
|
|
queue_namespace :pipeline_cache
|
2020-03-02 13:07:42 -05:00
|
|
|
urgency :high
|
2020-02-19 13:09:10 -05:00
|
|
|
idempotent!
|
2017-05-20 18:07:36 -04:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-05-22 14:22:50 -04:00
|
|
|
def perform(job_id)
|
|
|
|
job = CommitStatus.joins(:pipeline, :project).find_by(id: job_id)
|
2017-05-20 18:07:36 -04:00
|
|
|
return unless job
|
|
|
|
|
|
|
|
pipeline = job.pipeline
|
|
|
|
project = job.project
|
|
|
|
|
2017-05-22 14:22:50 -04:00
|
|
|
Gitlab::EtagCaching::Store.new.tap do |store|
|
|
|
|
store.touch(project_pipeline_path(project, pipeline))
|
|
|
|
store.touch(project_job_path(project, job))
|
|
|
|
end
|
2017-05-20 18:07:36 -04:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-05-20 18:07:36 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_pipeline_path(project, pipeline)
|
2017-06-29 13:06:35 -04:00
|
|
|
Gitlab::Routing.url_helpers.project_pipeline_path(project, pipeline, format: :json)
|
2017-05-20 18:07:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def project_job_path(project, job)
|
2017-06-29 13:06:35 -04:00
|
|
|
Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json)
|
2017-05-20 18:07:36 -04:00
|
|
|
end
|
|
|
|
end
|