Skip to content

Commit

Permalink
Fix/domain list delay (#391)
Browse files Browse the repository at this point in the history
* 3.28.4-beta.0

* 3.28.4

* adding delayTime parameter for domain list API
  • Loading branch information
just-at-uber authored Aug 18, 2021
1 parent 4deb7e2 commit 94e365a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const { delay } = require('../../../helpers');

const fetchDomainListNextPage = async ({
ctx,
delayTime = DOMAIN_LIST_DELAY_MS,
domainList = [],
nextPageToken = '',
pageSize = DOMAIN_LIST_PAGE_SIZE,
Expand All @@ -53,10 +54,11 @@ const fetchDomainListNextPage = async ({
error}`
);

await delay(DOMAIN_LIST_DELAY_MS);
await delay(delayTime);

return fetchDomainListNextPage({
ctx,
delayTime,
nextPageToken,
domainList,
pageSize,
Expand All @@ -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);
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion server/router/services/domain-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down

0 comments on commit 94e365a

Please sign in to comment.