Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 505adcb

Browse files
author
dengjun
committed
output from challenge: 30191400
1 parent ac43db4 commit 505adcb

File tree

14 files changed

+871
-744
lines changed

14 files changed

+871
-744
lines changed

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": false
3+
}

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
URL: {
1111
BASE: "https://www.topcoder-dev.com",
1212
COMMUNITY_APP: "https://community-app.topcoder-dev.com",
13+
PLATFORM_WEBSITE_URL: "https://platform.topcoder-dev.com",
1314
},
1415
RECRUIT_API: process.env.RECRUIT_API || "https://www.topcoder-dev.com",
1516
// the server api base path

config/development.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
URL: {
1010
BASE: "https://www.topcoder-dev.com",
1111
COMMUNITY_APP: "https://community-app.topcoder-dev.com",
12+
PLATFORM_WEBSITE_URL: "https://platform.topcoder-dev.com",
1213
},
1314
};

config/production.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
URL: {
1010
BASE: "https://www.topcoder.com",
1111
COMMUNITY_APP: "https://community-app.topcoder.com",
12+
PLATFORM_WEBSITE_URL: "https://platform.topcoder.com",
1213
},
1314
};

src/actions/lookup.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,37 @@ async function getGigStatuses() {
2121
return service.getGigStatuses();
2222
}
2323

24+
/**
25+
* Gets all the countries.
26+
* @returns {Array} Array containing all countries
27+
*/
28+
async function getAllCountries() {
29+
// fetch the first page to see how many more fetches are necessary to get all
30+
const countries = await service.getPaginatedCountries();
31+
const {
32+
meta: { totalPages },
33+
} = countries;
34+
35+
const pagesMissing = totalPages - 1;
36+
37+
// fetch the other pages.
38+
const allPageResults = await Promise.all(
39+
[...Array(pagesMissing > 0 ? pagesMissing : 0)].map((_, index) => {
40+
const newPage = index + 2;
41+
42+
return service.getPaginatedCountries(newPage);
43+
})
44+
);
45+
46+
const newCountries = allPageResults.map((data) => data).flat();
47+
return [...countries, ...newCountries];
48+
}
49+
2450
export default createActions({
2551
GET_TAGS: getTags,
2652
GET_COMMUNITY_LIST: getCommunityList,
2753
CHECK_IS_LOGGED_IN: checkIsLoggedIn,
2854
GET_GIG_PHASES: getGigPhases,
2955
GET_GIG_STATUSES: getGigStatuses,
56+
GET_ALL_COUNTRIES: getAllCountries,
3057
});

0 commit comments

Comments
 (0)