diff --git a/server/router/services/domain-service/helpers/fetch-domain-list-next-page.js b/server/router/services/domain-service/helpers/fetch-domain-list-next-page.js index 3181e60c9..c55a8f49c 100644 --- a/server/router/services/domain-service/helpers/fetch-domain-list-next-page.js +++ b/server/router/services/domain-service/helpers/fetch-domain-list-next-page.js @@ -28,6 +28,7 @@ const { delay } = require('../../../helpers'); const fetchDomainListNextPage = async ({ ctx, + delayTime = DOMAIN_LIST_DELAY_MS, domainList = [], nextPageToken = '', pageSize = DOMAIN_LIST_PAGE_SIZE, @@ -53,10 +54,11 @@ const fetchDomainListNextPage = async ({ error}` ); - await delay(DOMAIN_LIST_DELAY_MS); + await delay(delayTime); return fetchDomainListNextPage({ ctx, + delayTime, nextPageToken, domainList, pageSize, @@ -65,7 +67,7 @@ const fetchDomainListNextPage = async ({ } console.log( - `fetchDomainListNextPage returned ${data.domains.length} entries and a nextPageToken = "${data.nextPageToken}" with a page size = ${pageSize}.` + `fetchDomainListNextPage returned ${data.domains.length} entries and a nextPageToken = "${data.nextPageToken}" with a page size = ${pageSize} and delayTime = ${delayTime}ms.` ); domainList.splice(domainList.length, 0, ...data.domains); @@ -74,10 +76,11 @@ const fetchDomainListNextPage = async ({ return domainList; } - await delay(DOMAIN_LIST_DELAY_MS); + await delay(delayTime); return fetchDomainListNextPage({ ctx, + delayTime, nextPageToken: data.nextPageToken, domainList, pageSize, diff --git a/server/router/services/domain-service/helpers/fetch-domain-list.js b/server/router/services/domain-service/helpers/fetch-domain-list.js index e7a474e31..7315796c5 100644 --- a/server/router/services/domain-service/helpers/fetch-domain-list.js +++ b/server/router/services/domain-service/helpers/fetch-domain-list.js @@ -24,8 +24,12 @@ const fetchDomainListNextPage = require('./fetch-domain-list-next-page'); const filterDomainList = require('./filter-domain-list'); const sortDomainList = require('./sort-domain-list'); -const fetchDomainList = ({ ctx, pageSize }) => async () => { - const domainList = await fetchDomainListNextPage({ ctx, pageSize }); +const fetchDomainList = ({ ctx, delayTime, pageSize }) => async () => { + const domainList = await fetchDomainListNextPage({ + ctx, + delayTime, + pageSize, + }); return combine(domainList)(filterDomainList, sortDomainList); }; diff --git a/server/router/services/domain-service/helpers/get-domain-list.js b/server/router/services/domain-service/helpers/get-domain-list.js index 96d5cab70..ef762e7f1 100644 --- a/server/router/services/domain-service/helpers/get-domain-list.js +++ b/server/router/services/domain-service/helpers/get-domain-list.js @@ -21,7 +21,7 @@ const fetchDomainList = require('./fetch-domain-list'); -const getDomainList = ({ cacheManager, ctx, pageSize }) => - cacheManager.get(fetchDomainList({ ctx, pageSize })); +const getDomainList = ({ cacheManager, ctx, delayTime, pageSize }) => + cacheManager.get(fetchDomainList({ ctx, delayTime, pageSize })); module.exports = getDomainList; diff --git a/server/router/services/domain-service/index.js b/server/router/services/domain-service/index.js index 46ab00259..15126a13f 100644 --- a/server/router/services/domain-service/index.js +++ b/server/router/services/domain-service/index.js @@ -28,11 +28,12 @@ class DomainService { async searchDomains(ctx) { const { cacheManager } = this; - const { all, pageSize, querystring } = ctx.query; + const { all, delayTime, pageSize, querystring } = ctx.query; const domainList = await getDomainList({ cacheManager, ctx, + delayTime, pageSize, });