Skip to content

Commit 011284b

Browse files
committed
fix for issue #4384
1 parent 1aaf110 commit 011284b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/services/challenges.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,12 @@ class ChallengesService {
146146
};
147147
const url = `${endpoint}?${qs.stringify(query)}`;
148148
const res = await this.private.apiV5.get(url).then(checkErrorV5);
149-
150-
const memberId = decodeToken(this.private.tokenV3).userId;
151-
let myChallenges = {};
152-
if (memberId) { // if token then check myChallenges count
153-
myChallenges = await this.private.apiV5.get(`/resources/${memberId}/challenges`).then(checkErrorV5);
154-
}
155-
156149
return {
157150
challenges: res.result || [],
158151
totalCount: res.headers.get('x-total'),
159152
meta: {
160153
allChallengesCount: res.headers.get('x-total'),
161-
myChallengesCount: (myChallenges.result && myChallenges.result.length) || 0,
154+
myChallengesCount: 0,
162155
ongoingChallengesCount: 0,
163156
openChallengesCount: 0,
164157
totalCount: res.headers.get('x-total'),
@@ -450,16 +443,22 @@ class ChallengesService {
450443
/**
451444
* Gets challenges of the specified user.
452445
* @param {String} userId User id whose challenges we want to fetch.
453-
* @param {Object} filters Optional.
454-
* @param {Number} params Optional.
455446
* @return {Promise} Resolves to the api response.
456447
*/
457-
getUserChallenges(userId) {
448+
getUserChallenges(userId, filters, params) {
449+
const userFilters = _.cloneDeep(filters);
450+
ChallengesService.updateFiltersParamsForGettingMemberChallenges(userFilters, params);
458451
return this.private.apiV5.get(`/resources/${userId}/challenges`)
459452
.then(checkErrorV5).then((userChallenges) => {
460-
const param = { ids: userChallenges.result };
461-
const endpoint = `/challenges?${qs.stringify(param)}`;
462-
return this.private.apiV5.get(endpoint)
453+
const query = {
454+
...params,
455+
...userFilters,
456+
ids: userChallenges.result,
457+
};
458+
const endpoint = '/challenges';
459+
const url = `${endpoint}?${qs.stringify(_.omit(query, ['limit', 'offset', 'technologies']))}`;
460+
461+
return this.private.apiV5.get(url)
463462
.then(checkErrorV5).then((res) => {
464463
res.result.forEach(item => normalizeChallenge(item, userId));
465464
const newResponse = {};

0 commit comments

Comments
 (0)