Skip to content
Snippets Groups Projects
Unverified Commit 9e89c93e authored by Toon Claes's avatar Toon Claes Committed by Kamil Trzcinski
Browse files

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
parent 26e24bbe
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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)
Loading
Loading
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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment