BigW Consortium Gitlab

expire_job_cache_worker.rb 811 Bytes
Newer Older
1 2 3 4
class ExpireJobCacheWorker
  include Sidekiq::Worker
  include BuildQueue

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

    pipeline = job.pipeline
    project = job.project

12 13 14 15
    Gitlab::EtagCaching::Store.new.tap do |store|
      store.touch(project_pipeline_path(project, pipeline))
      store.touch(project_job_path(project, job))
    end
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  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
end