2017-04-18 15:26:56 -04:00
|
|
|
class ExpirePipelineCacheWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
include PipelineQueue
|
|
|
|
|
2017-04-20 02:44:01 -04:00
|
|
|
def perform(pipeline_id)
|
2017-04-21 11:39:19 -04:00
|
|
|
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
|
|
|
|
return unless pipeline
|
|
|
|
|
2017-04-18 15:26:56 -04:00
|
|
|
project = pipeline.project
|
|
|
|
store = Gitlab::EtagCaching::Store.new
|
|
|
|
|
|
|
|
store.touch(project_pipelines_path(project))
|
2017-05-20 18:07:36 -04:00
|
|
|
store.touch(project_pipeline_path(project, pipeline))
|
2017-04-18 15:26:56 -04:00
|
|
|
store.touch(commit_pipelines_path(project, pipeline.commit)) if pipeline.commit
|
|
|
|
store.touch(new_merge_request_pipelines_path(project))
|
2017-04-21 11:39:19 -04:00
|
|
|
each_pipelines_merge_request_path(project, pipeline) do |path|
|
|
|
|
store.touch(path)
|
|
|
|
end
|
2017-04-18 15:26:56 -04:00
|
|
|
|
|
|
|
Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_pipelines_path(project)
|
|
|
|
Gitlab::Routing.url_helpers.namespace_project_pipelines_path(
|
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
2017-05-20 18:07:36 -04:00
|
|
|
def project_pipeline_path(project, pipeline)
|
|
|
|
Gitlab::Routing.url_helpers.namespace_project_pipeline_path(
|
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
pipeline,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
2017-04-18 15:26:56 -04:00
|
|
|
def commit_pipelines_path(project, commit)
|
|
|
|
Gitlab::Routing.url_helpers.pipelines_namespace_project_commit_path(
|
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
commit.id,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
|
|
|
def new_merge_request_pipelines_path(project)
|
|
|
|
Gitlab::Routing.url_helpers.new_namespace_project_merge_request_path(
|
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
2017-04-21 11:39:19 -04:00
|
|
|
def each_pipelines_merge_request_path(project, pipeline)
|
|
|
|
pipeline.all_merge_requests.each do |merge_request|
|
|
|
|
path = Gitlab::Routing.url_helpers.pipelines_namespace_project_merge_request_path(
|
2017-04-18 15:26:56 -04:00
|
|
|
project.namespace,
|
|
|
|
project,
|
|
|
|
merge_request,
|
|
|
|
format: :json)
|
2017-04-21 11:39:19 -04:00
|
|
|
|
|
|
|
yield(path)
|
2017-04-18 15:26:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|