Skip to content

Challenge 30124821 #166

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
May 19, 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
1 change: 0 additions & 1 deletion __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ Object {
"default": undefined,
"getService": [Function],
"normalizeChallenge": [Function],
"normalizeChallengeDetails": [Function],
},
"communities": Object {
"default": undefined,
Expand Down
8 changes: 4 additions & 4 deletions docs/services.challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This module provides a service for convenient manipulation with
* [.close(challengeId, winnerId)](#module_services.challenges..ChallengesService+close) ⇒ <code>Promise</code>
* [.createTask(projectId, accountId, title, description, assignee, payment)](#module_services.challenges..ChallengesService+createTask) ⇒ <code>Promise</code>
* [.getChallengeDetails(challengeId)](#module_services.challenges..ChallengesService+getChallengeDetails) ⇒ <code>Promise</code>
* [.getChallengeSubtracks()](#module_services.challenges..ChallengesService+getChallengeSubtracks) ⇒ <code>Promise</code>
* [.getChallengeTypes()](#module_services.challenges..ChallengesService+getChallengeTypes) ⇒ <code>Promise</code>
* [.getChallengeTags()](#module_services.challenges..ChallengesService+getChallengeTags) ⇒ <code>Promise</code>
* [.getChallenges(filters, params)](#module_services.challenges..ChallengesService+getChallenges) ⇒ <code>Promise</code>
* [.getMarathonMatches(filters, params)](#module_services.challenges..ChallengesService+getMarathonMatches) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -119,7 +119,7 @@ Challenge service.
* [.close(challengeId, winnerId)](#module_services.challenges..ChallengesService+close) ⇒ <code>Promise</code>
* [.createTask(projectId, accountId, title, description, assignee, payment)](#module_services.challenges..ChallengesService+createTask) ⇒ <code>Promise</code>
* [.getChallengeDetails(challengeId)](#module_services.challenges..ChallengesService+getChallengeDetails) ⇒ <code>Promise</code>
* [.getChallengeSubtracks()](#module_services.challenges..ChallengesService+getChallengeSubtracks) ⇒ <code>Promise</code>
* [.getChallengeTypes()](#module_services.challenges..ChallengesService+getChallengeTypes) ⇒ <code>Promise</code>
* [.getChallengeTags()](#module_services.challenges..ChallengesService+getChallengeTags) ⇒ <code>Promise</code>
* [.getChallenges(filters, params)](#module_services.challenges..ChallengesService+getChallenges) ⇒ <code>Promise</code>
* [.getMarathonMatches(filters, params)](#module_services.challenges..ChallengesService+getMarathonMatches) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -203,9 +203,9 @@ incorrect in the main v3 endpoint. This may change in the future.
| --- | --- |
| challengeId | <code>Number</code> \| <code>String</code> |

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

#### challengesService.getChallengeSubtracks() ⇒ <code>Promise</code>
#### challengesService.getChallengeTypes() ⇒ <code>Promise</code>
Gets possible challenge subtracks.

**Kind**: instance method of [<code>ChallengesService</code>](#module_services.challenges..ChallengesService)
Expand Down
4 changes: 2 additions & 2 deletions src/actions/member-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function getDone(uuid, projectId, pageNum, tokenV3) {
isTask: 1,
projectId,
}, {
limit: PAGE_SIZE,
offset: pageNum * PAGE_SIZE,
perPage: PAGE_SIZE,
page: pageNum + 1,
}).then(({ challenges, totalCount }) => ({
projectId,
tasks: challenges,
Expand Down
8 changes: 4 additions & 4 deletions src/actions/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ async function getActiveChallengesInit(handle, uuid) {
* @returns {Object} Payload
*/
async function getActiveChallengesDone(handle, uuid, tokenV3) {
const filter = { status: 'ACTIVE' };
const filter = { status: 'Active' };
const service = getChallengesService(tokenV3);
/* TODO: Reuse `getAll` from `actions/challenge-listing`
/* after it moved from `community-app` to here.
*/
function getAll(getter, page = 0, prev = null) {
const PAGE_SIZE = 50;
return getter({
limit: PAGE_SIZE,
offset: page * PAGE_SIZE,
perPage: PAGE_SIZE,
page: page + 1,
}).then(({ challenges: chunk }) => {
if (!chunk.length) return prev || [];
return getAll(getter, 1 + page, prev ? prev.concat(chunk) : chunk);
Expand Down Expand Up @@ -247,7 +247,7 @@ async function getSubtrackChallengesDone(
refresh,
) {
const filter = {
status: 'completed',
status: 'Completed',
hasUserSubmittedForReview: 'true',
track,
subTrack,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function getCommunityStatsDone(community, uuid, challenges, token) {
/* TODO: At the moment, this component loads challenge objects to calculate
* the number of challenges and the total prize. Probably in future, we'll
* have a special API to get these data. */
let filtered = challenges.filter(x => x.status === 'ACTIVE');
let filtered = challenges.filter(x => x.status === 'Active');
if (community.challengeFilter) {
const filterFunction = Filter.getFilterFunction(community.challengeFilter);
filtered = filtered.filter(filterFunction);
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export function factory(options = {}) {
const checkpointsPromise = track === 'design' ? (
redux.resolveAction(actions.challenge.fetchCheckpointsDone(tokens.tokenV2, challengeId))
) : null;
const resultsPromise = _.get(details, 'payload.status', '') === 'COMPLETED' ? (
const resultsPromise = _.get(details, 'payload.status', '') === 'Completed' ? (
redux.resolveAction(actions.challenge.loadResultsDone(tokens, challengeId, track))
) : null;
return Promise.all([details, checkpointsPromise, resultsPromise]);
Expand Down
10 changes: 5 additions & 5 deletions src/services/__mocks__/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function normalizeChallengeDetails(v3, v3Filtered, v3User, v2, username)
// Fill some derived data
const registrationOpen = _.some(
challenge.allPhases,
phase => phase.phaseType === 'Registration' && phase.phaseStatus === 'Open',
phase => phase.name === 'Registration' && phase.isOpen,
) ? 'Yes' : 'No';
_.defaults(challenge, {
communities: new Set([COMPETITION_TRACKS[challenge.track]]),
Expand Down Expand Up @@ -163,7 +163,7 @@ export function normalizeChallengeDetails(v3, v3Filtered, v3User, v2, username)
* @return {Object} Normalized challenge.
*/
export function normalizeChallenge(challenge, username) {
const registrationOpen = challenge.allPhases.filter(d => d.phaseType === 'Registration')[0].phaseStatus === 'Open' ? 'Yes' : 'No';
const registrationOpen = challenge.allPhases.filter(d => d.name === 'Registration')[0].isOpen ? 'Yes' : 'No';
const groups = {};
if (challenge.groupIds) {
challenge.groupIds.forEach((id) => {
Expand Down Expand Up @@ -250,10 +250,10 @@ class ChallengesService {
}

/**
* Gets possible challenge subtracks.
* @return {Promise} Resolves to the array of subtrack names.
* Gets possible challenge types.
* @return {Promise} Resolves to the array of challenge type names.
*/
getChallengeSubtracks() {
getChallengeTypes() {
return Promise.all([
this.private.apiV2.get('/design/challengetypes')
.then(res => (res.ok ? res.json() : new Error(res.statusText))),
Expand Down
Loading