Skip to content

Commit e34065c

Browse files
author
liuliquan
authored
Merge pull request #700 from topcoder-platform/dev
Merge branch 'dev' into CORE-40
2 parents ba99505 + 80e3284 commit e34065c

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

src/common/helper.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,16 +1139,41 @@ async function getMembersByHandles(handles) {
11391139
* @returns {Object}
11401140
*/
11411141
async function getStandSkills(ids) {
1142+
1143+
const queryBatches = [];
1144+
const skillIdArg = "&skillId=";
1145+
let queryString = "disablePagination=true";
1146+
1147+
for (const id of ids) {
1148+
const enid = encodeURIComponent(id);
1149+
// When many skill ids, the query string will exceed 2048 limit
1150+
if (queryString.length + skillIdArg.length + enid.length < 2048) {
1151+
queryString += skillIdArg + enid;
1152+
} else {
1153+
queryBatches.push(queryString);
1154+
queryString = "disablePagination=true" + skillIdArg + enid;
1155+
}
1156+
}
1157+
queryBatches.push(queryString);
1158+
1159+
const skillDataPromises = [];
11421160
const token = await m2mHelper.getM2MToken();
1143-
const res = await axios.get(`${config.API_BASE_URL}/v5/standardized-skills/skills`, {
1144-
headers: { Authorization: `Bearer ${token}` },
1145-
params: {
1146-
page: 1,
1147-
perPage: ids.length,
1148-
skillId: ids,
1149-
},
1150-
});
1151-
return res.data;
1161+
for (const batch of queryBatches) {
1162+
skillDataPromises.push(
1163+
(async () => {
1164+
const res = await axios.get(
1165+
`${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`,
1166+
{
1167+
headers: { Authorization: `Bearer ${token}` },
1168+
}
1169+
);
1170+
return res.data;
1171+
})()
1172+
);
1173+
}
1174+
1175+
const data = await Promise.all(skillDataPromises);
1176+
return _.concat(...data);
11521177
}
11531178

11541179
/**

0 commit comments

Comments
 (0)