Skip to content

Commit ec5dc90

Browse files
committed
fix for issue #4375 & #4376
1 parent 0c3b90e commit ec5dc90

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/services/challenges.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,18 @@ class ChallengesService {
146146
};
147147
const url = `${endpoint}?${qs.stringify(query)}`;
148148
const res = await this.private.apiV5.get(url).then(checkErrorV5);
149+
let myChallengesCount = 0;
150+
if (typeof this.private.tokenV3 !== 'undefined') {
151+
const { userId } = decodeToken(this.private.tokenV3);
152+
myChallengesCount = await this.private.apiV5.get(`/resources/${userId}/challenges`)
153+
.then(checkErrorV5).then(userChallenges => userChallenges.headers.get('x-total'));
154+
}
149155
return {
150156
challenges: res.result || [],
151157
totalCount: res.headers.get('x-total'),
152158
meta: {
153159
allChallengesCount: res.headers.get('x-total'),
154-
myChallengesCount: 0,
160+
myChallengesCount,
155161
ongoingChallengesCount: 0,
156162
openChallengesCount: 0,
157163
totalCount: res.headers.get('x-total'),

src/utils/challenge/filter.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ function filterByEndDate(challenge, state) {
127127

128128
function filterByStarted(challenge, state) {
129129
if (_.isUndefined(state.started)) return true;
130-
if (!challenge.phases) {
131-
return true;
132-
}
133-
return _.some(challenge.phases, { isOpen: true, name: 'Registration' });
130+
return moment(challenge.registrationStartDate).isBefore(Date.now());
134131
}
135132

136133
function filterByStatus(challenge, state) {

0 commit comments

Comments
 (0)