Skip to content

fix for issue #4383 #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/actions/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ async function getActiveChallengesInit(handle, uuid) {
async function getActiveChallengesDone(handle, uuid, tokenV3) {
const filter = { status: 'Active' };
const service = getChallengesService(tokenV3);
const memberInfo = await getService(tokenV3).getMemberInfo(handle);
/* TODO: Reuse `getAll` from `actions/challenge-listing`
/* after it moved from `community-app` to here.
*/
Expand All @@ -160,7 +161,7 @@ async function getActiveChallengesDone(handle, uuid, tokenV3) {
});
}
const calls = [
getAll(params => service.getUserChallenges(handle, filter, params)),
getAll(params => service.getUserChallenges(memberInfo.userId, filter, params)),
];

const [challenges] = await Promise.all(calls);
Expand Down
35 changes: 14 additions & 21 deletions src/services/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,29 +452,22 @@ class ChallengesService {
const userFilters = _.cloneDeep(filters);
ChallengesService.updateFiltersParamsForGettingMemberChallenges(userFilters, params);

const userChallenges = await this.private.apiV5.get(`/resources/${userId}/challenges`)
.then(checkErrorV5).then(res => res);

let chResponse = null;
if (userChallenges.result && userChallenges.result.length > 0) {
const query = {
...params,
...userFilters,
ids: userChallenges.result,
};
const endpoint = '/challenges';
const url = `${endpoint}?${qs.stringify(_.omit(query, ['limit', 'offset', 'technologies']))}`;
chResponse = await this.private.apiV5.get(url)
.then(checkErrorV5).then((res) => {
res.result.forEach(item => normalizeChallenge(item, userId));
return res;
});
}
const query = {
...params,
...userFilters,
memberId: userId,
};
const url = `/challenges?${qs.stringify(_.omit(query, ['limit', 'offset', 'technologies']))}`;
const userChallenges = await this.private.apiV5.get(url)
.then(checkErrorV5)
.then((res) => {
res.result.forEach(item => normalizeChallenge(item, userId));
return res.result;
});

const chResult = (chResponse && chResponse.result) || [];
return {
challenges: chResult,
totalCount: chResult.length,
challenges: userChallenges,
totalCount: userChallenges.length,
};
}

Expand Down