Enable polling for pipelines table other pages
Also poll for pipeline changes on: - Pipeline table on commit page - Pipeline table on merge request page - Pipeline table on new merge request page
This commit is contained in:
parent
26e24bbe53
commit
9e89c93e16
5 changed files with 54 additions and 3 deletions
|
@ -35,6 +35,8 @@ class Projects::CommitController < Projects::ApplicationController
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
Gitlab::PollingInterval.set_header(response, interval: 10_000)
|
||||
|
||||
render json: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
.represent(@pipelines)
|
||||
|
|
|
@ -233,6 +233,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
format.json do
|
||||
Gitlab::PollingInterval.set_header(response, interval: 10_000)
|
||||
|
||||
render json: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
.represent(@pipelines)
|
||||
|
@ -246,6 +248,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
format.json do
|
||||
define_pipelines_vars
|
||||
|
||||
Gitlab::PollingInterval.set_header(response, interval: 10_000)
|
||||
|
||||
render json: {
|
||||
pipelines: PipelineSerializer
|
||||
.new(project: @project, user: @current_user)
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
module Ci
|
||||
class ExpirePipelineCacheService < BaseService
|
||||
attr_reader :pipeline
|
||||
|
||||
def execute(pipeline)
|
||||
@pipeline = pipeline
|
||||
store = Gitlab::EtagCaching::Store.new
|
||||
|
||||
Gitlab::EtagCaching::Store.new.touch(project_pipelines_path)
|
||||
store.touch(project_pipelines_path)
|
||||
store.touch(commit_pipelines_path)
|
||||
store.touch(new_merge_request_pipelines_path)
|
||||
merge_requests_pipelines_paths.each { |path| store.touch(path) }
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -14,5 +20,30 @@ module Ci
|
|||
project,
|
||||
format: :json)
|
||||
end
|
||||
|
||||
def commit_pipelines_path
|
||||
Gitlab::Routing.url_helpers.pipelines_namespace_project_commit_path(
|
||||
project.namespace,
|
||||
project,
|
||||
pipeline.commit.id,
|
||||
format: :json)
|
||||
end
|
||||
|
||||
def new_merge_request_pipelines_path
|
||||
Gitlab::Routing.url_helpers.new_namespace_project_merge_request_path(
|
||||
project.namespace,
|
||||
project,
|
||||
format: :json)
|
||||
end
|
||||
|
||||
def merge_requests_pipelines_paths
|
||||
pipeline.merge_requests.collect do |merge_request|
|
||||
Gitlab::Routing.url_helpers.pipelines_namespace_project_merge_request_path(
|
||||
project.namespace,
|
||||
project,
|
||||
merge_request,
|
||||
format: :json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,18 @@ module Gitlab
|
|||
{
|
||||
regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/pipelines\.json\z),
|
||||
name: 'project_pipelines'
|
||||
},
|
||||
{
|
||||
regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/commit/\s+/pipelines\.json\z),
|
||||
name: 'commit_pipelines'
|
||||
},
|
||||
{
|
||||
regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/merge_requests/new\.json\z),
|
||||
name: 'new_merge_request_pipelines'
|
||||
},
|
||||
{
|
||||
regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/merge_requests/\d+/pipelines\.json\z),
|
||||
name: 'merge_request_pipelines'
|
||||
}
|
||||
].freeze
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ describe Ci::ExpirePipelineCacheService, services: true do
|
|||
|
||||
describe '#execute' do
|
||||
it 'invalidate Etag caching for project pipelines path' do
|
||||
path = "/#{project.full_path}/pipelines.json"
|
||||
pipelines_path = "/#{project.full_path}/pipelines.json"
|
||||
new_mr_pipelines_path = "/#{project.full_path}/merge_requests/new.json"
|
||||
|
||||
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(path)
|
||||
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(pipelines_path)
|
||||
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(new_mr_pipelines_path)
|
||||
|
||||
subject.execute(pipeline)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue