Commit bb4867bd authored by Brandon Labuschagne's avatar Brandon Labuschagne

Reduce DA pagerefresh rate

We no longer care about the age of the data
when we determine if data should be fetched.

Changelog: fixed
EE: true
parent 0a315e69
...@@ -185,7 +185,6 @@ export default { ...@@ -185,7 +185,6 @@ export default {
pollTableData() { pollTableData() {
const shouldPoll = shouldPollTableData({ const shouldPoll = shouldPollTableData({
enabledNamespaces: this.devopsAdoptionEnabledNamespaces.nodes, enabledNamespaces: this.devopsAdoptionEnabledNamespaces.nodes,
timestamp: this.devopsAdoptionEnabledNamespaces?.nodes[0]?.latestSnapshot?.recordedAt,
openModal: this.openModal, openModal: this.openModal,
}); });
......
import { isToday } from '~/lib/utils/datetime_utility';
/** /**
* A helper function which accepts the enabledNamespaces, * A helper function which accepts the enabledNamespaces,
* *
* @param {Object} params the enabledNamespaces data, timestamp and check for open modals * @param {Object} params the enabledNamespaces data, and the check for open modals
* *
* @return {Boolean} a boolean to determine if table data should be polled * @return {Boolean} a boolean to determine if table data should be polled
*/ */
export const shouldPollTableData = ({ enabledNamespaces, timestamp, openModal }) => { export const shouldPollTableData = ({ enabledNamespaces, openModal }) => {
if (openModal) { if (openModal) {
return false; return false;
} else if (!enabledNamespaces.length) { } else if (!enabledNamespaces.length) {
...@@ -17,7 +15,6 @@ export const shouldPollTableData = ({ enabledNamespaces, timestamp, openModal }) ...@@ -17,7 +15,6 @@ export const shouldPollTableData = ({ enabledNamespaces, timestamp, openModal })
const anyPendingEnabledNamespaces = enabledNamespaces.some( const anyPendingEnabledNamespaces = enabledNamespaces.some(
(node) => node.latestSnapshot === null, (node) => node.latestSnapshot === null,
); );
const dataNotRefreshedToday = !isToday(new Date(timestamp));
return anyPendingEnabledNamespaces || dataNotRefreshedToday; return anyPendingEnabledNamespaces;
}; };
...@@ -4,18 +4,13 @@ import { devopsAdoptionNamespaceData } from '../mock_data'; ...@@ -4,18 +4,13 @@ import { devopsAdoptionNamespaceData } from '../mock_data';
describe('shouldPollTableData', () => { describe('shouldPollTableData', () => {
const { nodes: pendingData } = devopsAdoptionNamespaceData; const { nodes: pendingData } = devopsAdoptionNamespaceData;
const comepleteData = [pendingData[0]]; const comepleteData = [pendingData[0]];
const mockDate = '2020-07-06T00:00:00.000Z';
const previousDay = '2020-07-05T00:00:00.000Z';
it.each` it.each`
scenario | enabledNamespaces | timestamp | openModal | expected scenario | enabledNamespaces | openModal | expected
${'no namespaces data'} | ${[]} | ${mockDate} | ${false} | ${true} ${'no namespaces data'} | ${[]} | ${false} | ${true}
${'no timestamp'} | ${comepleteData} | ${null} | ${false} | ${true} ${'open modal'} | ${comepleteData} | ${true} | ${false}
${'open modal'} | ${comepleteData} | ${mockDate} | ${true} | ${false} ${'pending namespaces data, modal is closed'} | ${pendingData} | ${false} | ${true}
${'namespaces data, timestamp is today, modal is closed'} | ${comepleteData} | ${mockDate} | ${false} | ${false} ${'pending namespaces data, modal is open'} | ${pendingData} | ${true} | ${false}
${'namespaces data, timestamp is yesterday, modal is closed'} | ${comepleteData} | ${previousDay} | ${false} | ${true}
${'namespaces data, timestamp is today, modal is open'} | ${comepleteData} | ${mockDate} | ${true} | ${false}
${'pending namespaces data, timestamp is today, modal is closed'} | ${pendingData} | ${mockDate} | ${false} | ${true}
`('returns $expected when $scenario', ({ enabledNamespaces, timestamp, openModal, expected }) => { `('returns $expected when $scenario', ({ enabledNamespaces, timestamp, openModal, expected }) => {
expect(shouldPollTableData({ enabledNamespaces, timestamp, openModal })).toBe(expected); expect(shouldPollTableData({ enabledNamespaces, timestamp, openModal })).toBe(expected);
}); });
......
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