Commit fc0c9b6a authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/232478/updateWidgetIntervalForClosedMergeRequests' into 'master'

Change polling interval for merge request widget

Closes #232478

See merge request gitlab-org/gitlab!42458
parents 73bb15b0 fbb8bf94
...@@ -7,6 +7,7 @@ import stateMaps from 'ee_else_ce/vue_merge_request_widget/stores/state_maps'; ...@@ -7,6 +7,7 @@ import stateMaps from 'ee_else_ce/vue_merge_request_widget/stores/state_maps';
import { sprintf, s__, __ } from '~/locale'; import { sprintf, s__, __ } from '~/locale';
import Project from '~/pages/projects/project'; import Project from '~/pages/projects/project';
import SmartInterval from '~/smart_interval'; import SmartInterval from '~/smart_interval';
import { secondsToMilliseconds } from '~/lib/utils/datetime_utility';
import { deprecatedCreateFlash as createFlash } from '../flash'; import { deprecatedCreateFlash as createFlash } from '../flash';
import mergeRequestQueryVariablesMixin from './mixins/merge_request_query_variables'; import mergeRequestQueryVariablesMixin from './mixins/merge_request_query_variables';
import Loading from './components/loading.vue'; import Loading from './components/loading.vue';
...@@ -202,7 +203,10 @@ export default { ...@@ -202,7 +203,10 @@ export default {
}, },
mounted() { mounted() {
MRWidgetService.fetchInitialData() MRWidgetService.fetchInitialData()
.then(({ data }) => this.initWidget(data)) .then(({ data, headers }) => {
this.startingPollInterval = Number(headers['POLL-INTERVAL']);
this.initWidget(data);
})
.catch(() => .catch(() =>
createFlash(__('Unable to load the merge request widget. Try reloading the page.')), createFlash(__('Unable to load the merge request widget. Try reloading the page.')),
); );
...@@ -292,9 +296,10 @@ export default { ...@@ -292,9 +296,10 @@ export default {
initPolling() { initPolling() {
this.pollingInterval = new SmartInterval({ this.pollingInterval = new SmartInterval({
callback: this.checkStatus, callback: this.checkStatus,
startingInterval: 10 * 1000, startingInterval: this.startingPollInterval,
maxInterval: 240 * 1000, maxInterval: this.startingPollInterval + secondsToMilliseconds(4 * 60),
hiddenInterval: window.gon?.features?.widgetVisibilityPolling && 360 * 1000, hiddenInterval:
window.gon?.features?.widgetVisibilityPolling && secondsToMilliseconds(6 * 60),
incrementByFactorOf: 2, incrementByFactorOf: 2,
}); });
}, },
......
import { normalizeHeaders } from '~/lib/utils/common_utils';
import axios from '../../lib/utils/axios_utils'; import axios from '../../lib/utils/axios_utils';
export default class MRWidgetService { export default class MRWidgetService {
...@@ -82,6 +83,11 @@ export default class MRWidgetService { ...@@ -82,6 +83,11 @@ export default class MRWidgetService {
return Promise.all([ return Promise.all([
axios.get(window.gl.mrWidgetData.merge_request_cached_widget_path), axios.get(window.gl.mrWidgetData.merge_request_cached_widget_path),
axios.get(window.gl.mrWidgetData.merge_request_widget_path), axios.get(window.gl.mrWidgetData.merge_request_widget_path),
]).then(axios.spread((res, cachedRes) => ({ data: Object.assign(res.data, cachedRes.data) }))); ]).then(
axios.spread((res, cachedRes) => ({
data: Object.assign(res.data, cachedRes.data),
headers: normalizeHeaders(res.headers),
})),
);
} }
} }
---
title: Increase widget polling for closed and merged merge requests
merge_request: 42458
author:
type: changed
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