Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0d9c3ed

Browse files
committedApr 28, 2020
additional changes
1 parent 7f0fb64 commit 0d9c3ed

File tree

5 files changed

+90
-96
lines changed

5 files changed

+90
-96
lines changed
 

‎__tests__/__snapshots__/index.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,14 @@ Object {
239239
"countReset": [Function],
240240
"debug": [Function],
241241
"dir": [Function],
242-
"dirxml": [Function],
243242
"error": [Function],
244243
"group": [Function],
245244
"groupCollapsed": [Function],
246245
"groupEnd": [Function],
247246
"info": [Function],
248247
"log": [Function],
249-
"table": [Function],
250248
"time": [Function],
251249
"timeEnd": [Function],
252-
"timeLog": [Function],
253250
"trace": [Function],
254251
"warn": [Function],
255252
},

‎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.

‎docs/services.challenges.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module provides a service for convenient manipulation with
1818
* [.close(challengeId, winnerId)](#module_services.challenges..ChallengesService+close) ⇒ <code>Promise</code>
1919
* [.createTask(projectId, accountId, title, description, assignee, payment)](#module_services.challenges..ChallengesService+createTask) ⇒ <code>Promise</code>
2020
* [.getChallengeDetails(challengeId)](#module_services.challenges..ChallengesService+getChallengeDetails) ⇒ <code>Promise</code>
21-
* [.getChallengeSubtracks()](#module_services.challenges..ChallengesService+getChallengeSubtracks) ⇒ <code>Promise</code>
21+
* [.getChallengeTypes()](#module_services.challenges..ChallengesService+getChallengeTypes) ⇒ <code>Promise</code>
2222
* [.getChallengeTags()](#module_services.challenges..ChallengesService+getChallengeTags) ⇒ <code>Promise</code>
2323
* [.getChallenges(filters, params)](#module_services.challenges..ChallengesService+getChallenges) ⇒ <code>Promise</code>
2424
* [.getMarathonMatches(filters, params)](#module_services.challenges..ChallengesService+getMarathonMatches) ⇒ <code>Promise</code>
@@ -119,7 +119,7 @@ Challenge service.
119119
* [.close(challengeId, winnerId)](#module_services.challenges..ChallengesService+close) ⇒ <code>Promise</code>
120120
* [.createTask(projectId, accountId, title, description, assignee, payment)](#module_services.challenges..ChallengesService+createTask) ⇒ <code>Promise</code>
121121
* [.getChallengeDetails(challengeId)](#module_services.challenges..ChallengesService+getChallengeDetails) ⇒ <code>Promise</code>
122-
* [.getChallengeSubtracks()](#module_services.challenges..ChallengesService+getChallengeSubtracks) ⇒ <code>Promise</code>
122+
* [.getChallengeTypes()](#module_services.challenges..ChallengesService+getChallengeTypes) ⇒ <code>Promise</code>
123123
* [.getChallengeTags()](#module_services.challenges..ChallengesService+getChallengeTags) ⇒ <code>Promise</code>
124124
* [.getChallenges(filters, params)](#module_services.challenges..ChallengesService+getChallenges) ⇒ <code>Promise</code>
125125
* [.getMarathonMatches(filters, params)](#module_services.challenges..ChallengesService+getMarathonMatches) ⇒ <code>Promise</code>
@@ -203,9 +203,9 @@ incorrect in the main v3 endpoint. This may change in the future.
203203
| --- | --- |
204204
| challengeId | <code>Number</code> \| <code>String</code> |
205205

206-
<a name="module_services.challenges..ChallengesService+getChallengeSubtracks"></a>
206+
<a name="module_services.challenges..ChallengesService+getChallengeTypes"></a>
207207

208-
#### challengesService.getChallengeSubtracks() ⇒ <code>Promise</code>
208+
#### challengesService.getChallengeTypes() ⇒ <code>Promise</code>
209209
Gets possible challenge subtracks.
210210

211211
**Kind**: instance method of [<code>ChallengesService</code>](#module_services.challenges..ChallengesService)

‎src/services/__mocks__/challenges.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ class ChallengesService {
250250
}
251251

252252
/**
253-
* Gets possible challenge subtracks.
254-
* @return {Promise} Resolves to the array of subtrack names.
253+
* Gets possible challenge types.
254+
* @return {Promise} Resolves to the array of challenge type names.
255255
*/
256-
getChallengeSubtracks() {
256+
getChallengeTypes() {
257257
return Promise.all([
258258
this.private.apiV2.get('/design/challengetypes')
259259
.then(res => (res.ok ? res.json() : new Error(res.statusText))),

‎src/services/challenges.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
5757
numberOfCheckpointsPrizes: challenge.numberOfCheckpointsPrizes,
5858
topCheckPointPrize: challenge.topCheckPointPrize,
5959
submissionsViewable: challenge.submissionsViewable || 'false',
60-
reviewType: challenge.reviewType,
6160
allowStockArt: challenge.allowStockArt === 'true',
6261
fileTypes: challenge.filetypes || [],
6362
environment: challenge.environment,
@@ -66,12 +65,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
6665
submissionLimit: Number(challenge.submissionLimit) || 0,
6766
drPoints: challenge.digitalRunPoints,
6867
directUrl: challenge.directUrl,
69-
tags: _.union(
70-
challenge.technologies || [],
71-
challenge.technology || [],
72-
challenge.platforms || [],
73-
challenge.tags || [],
74-
),
68+
tags: challenge.tags || [],
7569
prizes: challenge.prize || challenge.prizes || [],
7670
events: _.map(challenge.event, e => ({
7771
eventName: e.eventShortDesc,
@@ -191,8 +185,7 @@ export function normalizeChallenge(challenge, username) {
191185
if (!challenge.totalPrize) {
192186
challenge.totalPrize = challenge.prizes.reduce((sum, x) => sum + x, 0);
193187
}
194-
if (!challenge.technologies) challenge.technologies = [];
195-
if (!challenge.platforms) challenge.platforms = [];
188+
if (!challenge.tags) challenge.tags = [];
196189

197190
if (challenge.subTrack === 'DEVELOP_MARATHON_MATCH') {
198191
challenge.track = 'DATA_SCIENCE';
@@ -338,7 +331,12 @@ class ChallengesService {
338331
* is rejected.
339332
*/
340333
async activate(challengeId) {
341-
let res = await this.private.api.post(`/challenges/${challengeId}/activate`);
334+
const params = {
335+
status: 'Active',
336+
};
337+
338+
let res = await this.private.apiV5.patch(`/challenge/${challengeId}`, params);
339+
342340
if (!res.ok) throw new Error(res.statusText);
343341
res = (await res.json()).result;
344342
if (res.status !== 200) throw new Error(res.content);
@@ -348,15 +346,14 @@ class ChallengesService {
348346
/**
349347
* Closes the specified challenge.
350348
* @param {Number} challengeId
351-
* @param {Number} winnerId Optional. ID of the assignee to declare the
352-
* winner.
353349
* @return {Promise} Resolves to null value in case of success; otherwise it
354350
* is rejected.
355351
*/
356-
async close(challengeId, winnerId) {
357-
let url = `/challenges/${challengeId}/close`;
358-
if (winnerId) url = `${url}?winnerId=${winnerId}`;
359-
let res = await this.private.api.post(url);
352+
async close(challengeId) {
353+
const params = {
354+
status: 'Completed',
355+
};
356+
let res = await this.private.apiV5.patch(`/challenges/${challengeId}/close`, params);
360357
if (!res.ok) throw new Error(res.statusText);
361358
res = (await res.json()).result;
362359
if (res.status !== 200) throw new Error(res.content);
@@ -374,7 +371,7 @@ class ChallengesService {
374371
* @param {String} submissionGuidelines
375372
* @param {Number} copilotId
376373
* @param {Number} copilotFee
377-
* @param {?} technologies
374+
* @param {?} tags
378375
* @return {Promise} Resolves to the created challenge object (payment task).
379376
*/
380377
async createTask(
@@ -387,7 +384,7 @@ class ChallengesService {
387384
submissionGuidelines,
388385
copilotId,
389386
copilotFee,
390-
technologies,
387+
tags,
391388
) {
392389
const payload = {
393390
param: {
@@ -398,7 +395,7 @@ class ChallengesService {
398395
submissionGuidelines,
399396
milestoneId: 1,
400397
name: title,
401-
technologies,
398+
tags,
402399
prizes: payment ? [payment] : [],
403400
projectId,
404401
registrationStartsAt: moment().toISOString(),
@@ -466,11 +463,11 @@ class ChallengesService {
466463
}
467464

468465
/**
469-
* Gets possible challenge subtracks.
466+
* Gets possible challenge types.
470467
* @return {Promise} Resolves to the array of subtrack names.
471468
*/
472-
getChallengeSubtracks() {
473-
return this.private.apiV5.get('/challengetypes')
469+
getChallengeTypes() {
470+
return this.private.apiV5.get('/challenge-types')
474471
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
475472
.then(res => (
476473
res.message

0 commit comments

Comments
 (0)
Please sign in to comment.