BigW Consortium Gitlab

expire_job_cache_worker.rb 743 Bytes
Newer Older
1
class ExpireJobCacheWorker
2
  include ApplicationWorker
3 4
  include PipelineQueue

5
  queue_namespace :pipeline_cache
6

7 8
  def perform(job_id)
    job = CommitStatus.joins(:pipeline, :project).find_by(id: job_id)
9 10 11 12 13
    return unless job

    pipeline = job.pipeline
    project = job.project

14 15 16 17
    Gitlab::EtagCaching::Store.new.tap do |store|
      store.touch(project_pipeline_path(project, pipeline))
      store.touch(project_job_path(project, job))
    end
18 19 20 21 22
  end

  private

  def project_pipeline_path(project, pipeline)
23
    Gitlab::Routing.url_helpers.project_pipeline_path(project, pipeline, format: :json)
24 25 26
  end

  def project_job_path(project, job)
27
    Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json)
28 29
  end
end