Commit 602aca9d authored by Igor Drozdov's avatar Igor Drozdov

Increase poll interval for merged MRs widget

parent 7d3a2cfb
......@@ -10,6 +10,9 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl
before_action :set_polling_header
around_action :allow_gitaly_ref_name_caching
FAST_POLLING_INTERVAL = 10.seconds.in_milliseconds
SLOW_POLLING_INTERVAL = 5.minutes.in_milliseconds
def widget
respond_to do |format|
format.json do
......@@ -29,7 +32,8 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl
private
def set_polling_header
Gitlab::PollingInterval.set_header(response, interval: 10_000)
interval = merge_request.open? ? FAST_POLLING_INTERVAL : SLOW_POLLING_INTERVAL
Gitlab::PollingInterval.set_header(response, interval: interval)
end
def serializer(entity)
......
---
title: Increase poll interval for merged MRs widget
merge_request: 39961
author:
type: performance
......@@ -48,6 +48,8 @@ RSpec.describe Projects::MergeRequests::ContentController do
expect(merge_request).to receive(:check_mergeability)
do_request(:widget)
expect(response.headers['Poll-Interval']).to eq('10000')
end
context 'merged merge request' do
......@@ -59,6 +61,7 @@ RSpec.describe Projects::MergeRequests::ContentController do
do_request(:widget)
expect(response).to match_response_schema('entities/merge_request_poll_widget')
expect(response.headers['Poll-Interval']).to eq('300000')
end
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