Skip to content

Commit ef75d52

Browse files
authored
Merge pull request topcoder-platform#239 from topcoder-platform/release-v5-develop
Release v5 develop
2 parents 4ee089d + 69f0308 commit ef75d52

File tree

3 files changed

+13
-34
lines changed

3 files changed

+13
-34
lines changed

src/actions/challenge.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { createActions } from 'redux-actions';
1010
import { decodeToken } from 'tc-accounts';
1111
import { getService as getChallengesService } from '../services/challenges';
1212
import { getService as getSubmissionService } from '../services/submissions';
13-
import { getService as getMemberService } from '../services/members';
1413
import { getApi } from '../services/api';
1514
import * as submissionUtil from '../utils/submission';
1615

@@ -147,25 +146,19 @@ function getMMSubmissionsInit(challengeId) {
147146
* @param {String} tokenV3 Topcoder auth token v3.
148147
* @return {Action}
149148
*/
150-
function getMMSubmissionsDone(challengeId, registrants, tokenV3) {
149+
function getMMSubmissionsDone(challengeId, tokenV3) {
151150
const filter = { challengeId };
152-
const memberService = getMemberService(tokenV3);
153151
const submissionsService = getSubmissionService(tokenV3);
154152

155153
// TODO: Move those numbers to configs
156154
return getAll(params => submissionsService.getSubmissions(filter, params), 1, 500)
157155
.then((submissions) => {
158-
const userIds = _.uniq(_.map(submissions, sub => sub.memberId));
159-
return memberService.getMembersInformation(userIds)
160-
.then((resources) => {
161-
const finalSubmissions = submissionUtil
162-
.processMMSubmissions(submissions, resources, registrants);
163-
return {
164-
challengeId,
165-
submissions: finalSubmissions,
166-
tokenV3,
167-
};
168-
});
156+
const finalSubmissions = submissionUtil.processMMSubmissions(submissions);
157+
return {
158+
challengeId,
159+
submissions: finalSubmissions,
160+
tokenV3,
161+
};
169162
});
170163
}
171164

src/services/challenges.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class ChallengesService {
328328
if (/^[\d]{5,8}$/.test(challengeId)) {
329329
isLegacyChallenge = true;
330330
challenge = await this.private.getChallenges('/challenges/', { legacyId: challengeId })
331-
.then(res => res.challenges[0]);
331+
.then(res => res.challenges[0] || {});
332332
} else {
333333
challenge = await this.private.getChallenges(`/challenges/${challengeId}`)
334334
.then(res => res.challenges);

src/utils/submission.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ function toFixed(num, decimal) {
3030
return result;
3131
}
3232

33-
function getMMChallengeHandleStyle(handle, registrants) {
34-
const style = _.get(_.find(registrants, m => m.handle === handle), 'colorStyle', null);
35-
if (style) return JSON.parse(style.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}'));
36-
return {};
37-
}
38-
3933
/**
4034
* Process each submission rank of MM challenge
4135
* @param submissions the array of submissions
@@ -118,21 +112,14 @@ export function getFinalScore(submission) {
118112
* @param resources the challenge resources
119113
* @param registrants the challenge registrants
120114
*/
121-
export function processMMSubmissions(submissions, resources, registrants) {
115+
export function processMMSubmissions(submissions) {
122116
const data = {};
123117
const result = [];
124118

125119
_.each(submissions, (submission) => {
126120
const { memberId } = submission;
127-
let memberHandle;
128-
const resource = _.find(resources, r => _.get(r, 'userId').toString() === memberId.toString());
129-
if (_.isEmpty(resource)) {
130-
memberHandle = memberId;
131-
} else {
132-
memberHandle = _.has(resource, 'handle') ? _.get(resource, 'handle') : memberId.toString();
133-
}
134-
if (!data[memberHandle]) {
135-
data[memberHandle] = [];
121+
if (!data[memberId]) {
122+
data[memberId] = [];
136123
}
137124
const validReviews = _.reject(submission.review, ['typeId', AV_SCAN_SCORER_REVIEW_TYPE_ID]);
138125
validReviews.sort((a, b) => {
@@ -149,7 +136,7 @@ export function processMMSubmissions(submissions, resources, registrants) {
149136
const provisionalScore = toFixed(_.get(validReviews, '[0].score', '-'), 5);
150137
const finalScore = toFixed(_.get(submission, 'reviewSummation[0].aggregateScore', '-'), 5);
151138

152-
data[memberHandle].push({
139+
data[memberId].push({
153140
submissionId: submission.id,
154141
submissionTime: submission.created,
155142
provisionalScore,
@@ -163,8 +150,7 @@ export function processMMSubmissions(submissions, resources, registrants) {
163150
result.push({
164151
submissions: [...value.sort((a, b) => new Date(b.submissionTime)
165152
.getTime() - new Date(a.submissionTime).getTime())],
166-
member: key,
167-
colorStyle: getMMChallengeHandleStyle(key, registrants),
153+
memberId: key,
168154
});
169155
});
170156

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy