Skip to content

Commit beca4f0

Browse files
authored
Merge pull request #4622 from topcoder-platform/issue-4583
Issue#4583 : Fix mySubmissions of MM challenges
2 parents afb21e5 + 1e9d7bb commit beca4f0

File tree

8 files changed

+59
-25
lines changed

8 files changed

+59
-25
lines changed

src/shared/components/challenge-detail/Header/TabSelector/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function ChallengeViewSelector(props) {
2121
const {
2222
isLoggedIn,
2323
challenge,
24+
isMM,
2425
checkpointCount,
2526
numOfRegistrants,
2627
numOfSubmissions,
@@ -32,8 +33,6 @@ export default function ChallengeViewSelector(props) {
3233
mySubmissions,
3334
} = props;
3435

35-
const challengeSubTrack = challenge.subTrack;
36-
const isMM = challengeSubTrack && challengeSubTrack.indexOf('MARATHON_MATCH') > -1;
3736
const forumId = _.get(challenge, 'forumId') || 0;
3837
const roles = _.get(challenge, 'userDetails.roles') || [];
3938

@@ -189,6 +188,7 @@ export default function ChallengeViewSelector(props) {
189188
ChallengeViewSelector.defaultProps = {
190189
isLoggedIn: false,
191190
challenge: {},
191+
isMM: false,
192192
checkpointCount: 0,
193193
numOfRegistrants: 0,
194194
numOfSubmissions: 0,
@@ -206,6 +206,7 @@ ChallengeViewSelector.propTypes = {
206206
roles: PT.arrayOf(PT.string),
207207
}),
208208
}),
209+
isMM: PT.bool,
209210
checkpointCount: PT.number,
210211
numOfRegistrants: PT.number,
211212
numOfSubmissions: PT.number,

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ export default function ChallengeHeader(props) {
450450
<TabSelector
451451
isLoggedIn={isLoggedIn}
452452
challenge={challenge}
453+
isMM={isMM(challenge)}
453454
onSelectorClicked={onSelectorClicked}
454455
trackLower={trackLower}
455456
selectedView={selectedView}

src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ SubmissionsListView.propTypes = {
465465
checkpoints: PT.arrayOf(PT.object),
466466
submissions: PT.arrayOf(PT.object),
467467
submissionViewable: PT.string,
468-
track: PT.string.isRequired,
468+
legacy: {
469+
track: PT.string.isRequired,
470+
}.isRequired,
469471
registrants: PT.any,
470-
subTrack: PT.any,
471472
}).isRequired,
472473
hasRegistered: PT.bool.isRequired,
473474
unregistering: PT.bool.isRequired,

src/shared/components/challenge-detail/MySubmissions/index.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ class MySubmissionsView extends React.Component {
2727
}
2828

2929
componentDidMount() {
30-
const { challenge, loadMMSubmissions, auth } = this.props;
31-
const isMM = challenge.subTrack.indexOf('MARATHON_MATCH') > -1;
30+
const {
31+
challenge,
32+
isMM,
33+
loadMMSubmissions,
34+
auth,
35+
} = this.props;
3236

3337
// Check auth token, go to login page if invalid
3438
if (isMM && (_.isEmpty(auth) || _.isEmpty(auth.tokenV3) || isTokenExpired(auth.tokenV3))) {
@@ -45,6 +49,7 @@ class MySubmissionsView extends React.Component {
4549
const {
4650
challengesUrl,
4751
challenge,
52+
isMM,
4853
hasRegistered,
4954
unregistering,
5055
submissionEnded,
@@ -81,6 +86,7 @@ class MySubmissionsView extends React.Component {
8186
hasRegistered={hasRegistered}
8287
unregistering={unregistering}
8388
submissionEnded={submissionEnded}
89+
isMM={isMM}
8490
isLegacyMM={isLegacyMM}
8591
mySubmissions={mySubmissions}
8692
auth={auth}
@@ -105,13 +111,15 @@ MySubmissionsView.propTypes = {
105111
checkpoints: PT.arrayOf(PT.object),
106112
submissions: PT.arrayOf(PT.object),
107113
submissionViewable: PT.string,
108-
track: PT.string.isRequired,
114+
legacy: {
115+
track: PT.string.isRequired,
116+
},
109117
registrants: PT.any,
110-
subTrack: PT.any,
111118
}).isRequired,
112119
hasRegistered: PT.bool.isRequired,
113120
unregistering: PT.bool.isRequired,
114121
submissionEnded: PT.bool.isRequired,
122+
isMM: PT.bool.isRequired,
115123
isLegacyMM: PT.bool.isRequired,
116124
loadingMMSubmissionsForChallengeId: PT.string.isRequired,
117125
auth: PT.shape().isRequired,

src/shared/components/challenge-detail/Submissions/SubmissionRow/SubmissionHistoryRow/index.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ SubmissionHistoryRow.propTypes = {
9797
member: PT.string.isRequired,
9898
isMM: PT.bool.isRequired,
9999
submission: PT.number.isRequired,
100-
finalScore: PT.number,
100+
finalScore: PT.oneOfType([
101+
PT.number,
102+
PT.string,
103+
]),
101104
status: PT.string.isRequired,
102-
provisionalScore: PT.number,
105+
provisionalScore: PT.oneOfType([
106+
PT.number,
107+
PT.string,
108+
]),
103109
submissionTime: PT.string.isRequired,
104110
isReviewPhaseComplete: PT.bool,
105111
submissionId: PT.string.isRequired,

src/shared/components/challenge-detail/Submissions/SubmissionRow/index.jsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,31 @@ SubmissionRow.propTypes = {
177177
openHistory: PT.bool.isRequired,
178178
member: PT.string.isRequired,
179179
submissions: PT.arrayOf(PT.shape({
180-
provisionalScore: PT.number,
181-
finalScore: PT.number,
182-
initialScore: PT.number,
180+
provisionalScore: PT.oneOfType([
181+
PT.number,
182+
PT.string,
183+
]),
184+
finalScore: PT.oneOfType([
185+
PT.number,
186+
PT.string,
187+
]),
188+
initialScore: PT.oneOfType([
189+
PT.number,
190+
PT.string,
191+
]),
183192
status: PT.string.isRequired,
184193
submissionId: PT.string.isRequired,
185194
submissionTime: PT.string.isRequired,
186195
})).isRequired,
187196
score: PT.shape({
188-
final: PT.number,
189-
provisional: PT.number,
197+
final: PT.oneOfType([
198+
PT.number,
199+
PT.string,
200+
]),
201+
provisional: PT.oneOfType([
202+
PT.number,
203+
PT.string,
204+
]),
190205
}),
191206
rating: PT.number,
192207
toggleHistory: PT.func,

src/shared/containers/challenge-detail/index.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import _ from 'lodash';
1010
import communityActions from 'actions/tc-communities';
11-
import { isMM } from 'utils/challenge';
11+
import { isMM as checkIsMM } from 'utils/challenge';
1212
import LoadingPagePlaceholder from 'components/LoadingPagePlaceholder';
1313
import pageActions from 'actions/page';
1414
import ChallengeHeader from 'components/challenge-detail/Header';
@@ -387,7 +387,8 @@ class ChallengeDetailPageContainer extends React.Component {
387387
? results : null;
388388

389389
const isEmpty = _.isEmpty(challenge);
390-
const isLegacyMM = isMM(challenge) && Boolean(challenge.roundId);
390+
const isMM = checkIsMM(challenge);
391+
const isLegacyMM = isMM && Boolean(challenge.roundId);
391392

392393
if (isLoadingChallenge || isLoadingTerms) {
393394
return <LoadingPagePlaceholder />;
@@ -556,7 +557,8 @@ class ChallengeDetailPageContainer extends React.Component {
556557
hasRegistered={challenge.isRegistered}
557558
unregistering={unregistering}
558559
submissionEnded={submissionEnded}
559-
isLegacyMM={isLegacyMM}
560+
isMM
561+
isLegacyMM
560562
loadingMMSubmissionsForChallengeId={loadingMMSubmissionsForChallengeId}
561563
auth={auth}
562564
loadMMSubmissions={loadMMSubmissions}
@@ -722,16 +724,14 @@ function mapStateToProps(state, props) {
722724
}));
723725
}
724726

725-
if (mmSubmissions) {
727+
if (!_.isEmpty(mmSubmissions)) {
726728
mmSubmissions = mmSubmissions.map((submission) => {
727729
let registrant;
728730
let { member } = submission;
729731
if (auth.user.handle === submission.member) {
730732
mySubmissions = submission.submissions || [];
731-
mySubmissions = mySubmissions.map((mySubmission, index) => {
732-
// eslint-disable-next-line no-param-reassign
733-
mySubmission.id = mySubmissions.length - index;
734-
return mySubmission;
733+
mySubmissions.forEach((mySubmission, index) => {
734+
mySubmissions[index].id = mySubmissions.length - index;
735735
});
736736
}
737737
let submissionDetail = _.find(challenge.submissions, { createdBy: submission.createdBy });
@@ -760,6 +760,8 @@ function mapStateToProps(state, props) {
760760
member,
761761
});
762762
});
763+
} else {
764+
mySubmissions = _.filter(challenge.submissions, s => (`${s.memberId}` === `${auth.user.userId}`));
763765
}
764766
}
765767
return {

src/shared/utils/challenge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import _ from 'lodash';
88
* @param {Object} challenge challenge object
99
*/
1010
export function isMM(challenge) {
11-
return challenge.challengeType && challenge.challengeType.name === 'Marathon Match';
11+
return challenge.type === 'Marathon Match';
1212
}
1313

1414
/**
1515
* check if is develop marathon match challenge
1616
* @param {Object} challenge challenge object
1717
*/
1818
export function isDevelopMM(challenge) {
19-
return challenge.challengeType && challenge.challengeType.name === 'Develop Marathon Match';
19+
return challenge.type === 'Develop Marathon Match';
2020
}
2121

2222
/**

0 commit comments

Comments
 (0)