Skip to content

Commit 680d357

Browse files
authored
Merge pull request #478 from topcoder-platform/develop
fix: optimize challenge listing and challenge creation endpoint
2 parents 6866edf + 5aa029e commit 680d357

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@
7575
},
7676
"engines": {
7777
"node": "10.x"
78+
},
79+
"volta": {
80+
"node": "10.22.1"
7881
}
7982
}

src/common/helper.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ async function getUserGroups (userId) {
645645
headers: { Authorization: `Bearer ${token}` },
646646
params: {
647647
page,
648-
perPage: 1000,
648+
perPage: 5000,
649649
memberId: userId,
650650
membershipType: 'user'
651651
}
@@ -669,16 +669,15 @@ async function getUserGroups (userId) {
669669
* @returns {Promise<Array>} the user groups
670670
*/
671671
async function getCompleteUserGroupTreeIds (userId) {
672-
const childGroups = await getUserGroups(userId)
673-
const childGroupIds = _.map(childGroups, 'id')
674-
let result = []
675-
for (const id of childGroupIds) {
676-
if (!result.includes(id)) {
677-
const expanded = await expandWithParentGroups(id)
678-
result = _.concat(result, expanded)
672+
const token = await getM2MToken()
673+
const result = await axios.get(`${config.GROUPS_API_URL}/memberGroups/${userId}`, {
674+
headers: { Authorization: `Bearer ${token}` },
675+
params: {
676+
uuid: true
679677
}
680-
}
681-
return _.uniq(result)
678+
})
679+
680+
return result.data || []
682681
}
683682

684683
/**

0 commit comments

Comments
 (0)