Skip to content

Commit 69f0308

Browse files
committed
Merge pull request #235 from topcoder-platform/issue-4730
MM Details Page - Fix submissions member handle color and ratings
1 parent 997eee1 commit 69f0308

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

src/actions/challenge.js

+7-14
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/utils/submission.js

+5-19
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)