Skip to content

Commit 7f0fb64

Browse files
committed
fix for challenge 30122528
1 parent b524069 commit 7f0fb64

File tree

5 files changed

+93
-86
lines changed

5 files changed

+93
-86
lines changed

__tests__/__snapshots__/index.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,17 @@ Object {
239239
"countReset": [Function],
240240
"debug": [Function],
241241
"dir": [Function],
242+
"dirxml": [Function],
242243
"error": [Function],
243244
"group": [Function],
244245
"groupCollapsed": [Function],
245246
"groupEnd": [Function],
246247
"info": [Function],
247248
"log": [Function],
249+
"table": [Function],
248250
"time": [Function],
249251
"timeEnd": [Function],
252+
"timeLog": [Function],
250253
"trace": [Function],
251254
"warn": [Function],
252255
},

dist/dev/index.js

Lines changed: 64 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/__mocks__/challenges.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function normalizeChallengeDetails(v3, v3Filtered, v3User, v2, username)
134134
// Fill some derived data
135135
const registrationOpen = _.some(
136136
challenge.allPhases,
137-
phase => phase.name === 'Registration' && phase.isActive,
137+
phase => phase.name === 'Registration' && phase.isOpen,
138138
) ? 'Yes' : 'No';
139139
_.defaults(challenge, {
140140
communities: new Set([COMPETITION_TRACKS[challenge.track]]),
@@ -163,7 +163,7 @@ export function normalizeChallengeDetails(v3, v3Filtered, v3User, v2, username)
163163
* @return {Object} Normalized challenge.
164164
*/
165165
export function normalizeChallenge(challenge, username) {
166-
const registrationOpen = challenge.allPhases.filter(d => d.name === 'Registration')[0].isActive ? 'Yes' : 'No';
166+
const registrationOpen = challenge.allPhases.filter(d => d.name === 'Registration')[0].isOpen ? 'Yes' : 'No';
167167
const groups = {};
168168
if (challenge.groupIds) {
169169
challenge.groupIds.forEach((id) => {

src/services/challenges.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
8080
})),
8181
terms: challenge.terms,
8282
submissions: challenge.submissions,
83-
track: _.toUpper(challenge.challengeCommunity),
8483
subTrack: challenge.subTrack,
8584
checkpoints: challenge.checkpoints,
8685
documents: challenge.documents || [],
@@ -147,7 +146,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
147146
// Fill some derived data
148147
const registrationOpen = _.some(
149148
allPhases,
150-
phase => phase.name === 'Registration' && phase.isActive,
149+
phase => phase.name === 'Registration' && phase.isOpen,
151150
) ? 'Yes' : 'No';
152151
_.defaults(finalChallenge, {
153152
communities: new Set([COMPETITION_TRACKS[finalChallenge.track]]),
@@ -180,7 +179,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
180179
* @param {String} username Optional.
181180
*/
182181
export function normalizeChallenge(challenge, username) {
183-
const registrationOpen = (challenge.allPhases || challenge.phases || []).filter(d => (d.name === 'Registration' || !d.name))[0].isActive ? 'Yes' : 'No';
182+
const registrationOpen = (challenge.allPhases || challenge.phases || []).filter(d => (d.name === 'Registration' || !d.name))[0].isOpen ? 'Yes' : 'No';
184183
const groups = {};
185184
if (challenge.groupIds) {
186185
challenge.groupIds.forEach((id) => {
@@ -511,18 +510,15 @@ class ChallengesService {
511510
/**
512511
* Gets SRM matches.
513512
* @param {Object} params
513+
* @param {string} typeId Challenge SRM TypeId
514514
* @return {Promise}
515515
*/
516516
async getSrms(params) {
517-
const res = await this.private.api.get(`/srms/?${qs.stringify(params)}`);
517+
const res = await this.private.apiV5.get(`/challenges/?${qs.stringify(params)}`);
518518
return getApiResponsePayload(res);
519519
}
520520

521521
static updateFiltersParamsForGettingMemberChallenges(filters, params) {
522-
if (filters && filters.status === 'Active') {
523-
// eslint-disable-next-line no-param-reassign
524-
filters.status = 'ACTIVE';
525-
}
526522
if (params && params.perPage) {
527523
// eslint-disable-next-line no-param-reassign
528524
params.offset = (params.page - 1) * params.perPage;
@@ -577,23 +573,31 @@ class ChallengesService {
577573
/**
578574
* Registers user to the specified challenge.
579575
* @param {String} challengeId
576+
* @param {String} memberHandle
577+
* @param {String} roleId
580578
* @return {Promise}
581579
*/
582-
async register(challengeId) {
583-
const endpoint = `/challenges/${challengeId}/register`;
584-
const res = await this.private.api.postJson(endpoint);
580+
async register(challengeId, memberHandle, roleId) {
581+
const params = {
582+
challengeId, memberHandle, roleId,
583+
};
584+
const res = await this.private.apiV5.post('/resources', params);
585585
if (!res.ok) throw new Error(res.statusText);
586586
return res.json();
587587
}
588588

589589
/**
590590
* Unregisters user from the specified challenge.
591591
* @param {String} challengeId
592+
* @param {String} memberHandle
593+
* @param {String} roleId
592594
* @return {Promise}
593595
*/
594-
async unregister(challengeId) {
595-
const endpoint = `/challenges/${challengeId}/unregister`;
596-
const res = await this.private.api.post(endpoint);
596+
async unregister(challengeId, memberHandle, roleId) {
597+
const params = {
598+
challengeId, memberHandle, roleId,
599+
};
600+
const res = await this.private.apiV5.post('/resources', params);
597601
if (!res.ok) throw new Error(res.statusText);
598602
return res.json();
599603
}

src/utils/challenge/filter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ function filterByRegistrationOpen(challenge, state) {
9090
return challenge.status !== 'Past';
9191
}
9292
const registrationPhase = (challenge.allPhases || challenge.phases || []).find(item => item.name === 'Registration');
93-
if (!registrationPhase || !registrationPhase.isActive) {
93+
if (!registrationPhase || !registrationPhase.isOpen) {
9494
return false;
9595
}
9696
if (challenge.track === 'DESIGN') {
9797
const checkpointPhase = (challenge.allPhases || challenge.phases || []).find(item => item.name === 'Checkpoint Submission');
98-
return !checkpointPhase || !checkpointPhase.isActive;
98+
return !checkpointPhase || !checkpointPhase.isOpen;
9999
}
100100
return true;
101101
};
@@ -123,7 +123,7 @@ function filterByStarted(challenge, state) {
123123
if (!challenge.phases) {
124124
return true;
125125
}
126-
return _.some(challenge.phases, { isActive: true, name: 'Registration' });
126+
return _.some(challenge.phases, { isOpen: true, name: 'Registration' });
127127
}
128128

129129
function filterByStatus(challenge, state) {
@@ -143,14 +143,14 @@ function filterBySubtracks(challenge, state) {
143143

144144
function filterByTags(challenge, state) {
145145
if (!state.tags) return true;
146-
const { platforms, technologies } = challenge;
147-
const str = `${platforms} ${technologies}`.toLowerCase();
146+
const { platforms, tags } = challenge;
147+
const str = `${platforms} ${tags}`.toLowerCase();
148148
return state.tags.some(tag => str.includes(tag.toLowerCase()));
149149
}
150150

151151
function filterByText(challenge, state) {
152152
if (!state.text) return true;
153-
const str = `${challenge.name} ${challenge.tags} ${challenge.platforms} ${challenge.technologies}`
153+
const str = `${challenge.name} ${challenge.tags} ${challenge.platforms} ${challenge.tags}`
154154
.toLowerCase();
155155
return str.includes(state.text.toLowerCase());
156156
}

0 commit comments

Comments
 (0)