Commit 9e89c93e authored by Toon Claes's avatar Toon Claes Committed by Kamil Trzcinski

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
...@@ -35,6 +35,8 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -35,6 +35,8 @@ class Projects::CommitController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
Gitlab::PollingInterval.set_header(response, interval: 10_000)
render json: PipelineSerializer render json: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
.represent(@pipelines) .represent(@pipelines)
......
...@@ -233,6 +233,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -233,6 +233,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
format.json do format.json do
Gitlab::PollingInterval.set_header(response, interval: 10_000)
render json: PipelineSerializer render json: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
.represent(@pipelines) .represent(@pipelines)
...@@ -246,6 +248,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -246,6 +248,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format.json do format.json do
define_pipelines_vars define_pipelines_vars
Gitlab::PollingInterval.set_header(response, interval: 10_000)
render json: { render json: {
pipelines: PipelineSerializer pipelines: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
......
module Ci module Ci
class ExpirePipelineCacheService < BaseService class ExpirePipelineCacheService < BaseService
attr_reader :pipeline
def execute(pipeline) def execute(pipeline)
@pipeline = 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 end
private private
...@@ -14,5 +20,30 @@ module Ci ...@@ -14,5 +20,30 @@ module Ci
project, project,
format: :json) format: :json)
end 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
end end
...@@ -14,6 +14,18 @@ module Gitlab ...@@ -14,6 +14,18 @@ module Gitlab
{ {
regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/pipelines\.json\z), regexp: %r(^(?!.*(#{RESERVED_WORDS})).*/pipelines\.json\z),
name: 'project_pipelines' 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 ].freeze
......
...@@ -8,9 +8,11 @@ describe Ci::ExpirePipelineCacheService, services: true do ...@@ -8,9 +8,11 @@ describe Ci::ExpirePipelineCacheService, services: true do
describe '#execute' do describe '#execute' do
it 'invalidate Etag caching for project pipelines path' 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) subject.execute(pipeline)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment