Skip to content

Commit 405ec60

Browse files
committed
Adds challenge normalizations for legacy Marathon Matches. Fixes sorting for new MMs.
1 parent 0c39928 commit 405ec60

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3232
"test": "npm run lint && npm run jest"
3333
},
34-
"version": "0.5.0-0",
34+
"version": "0.5.0-1",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"isomorphic-fetch": "^2.2.1",

src/services/challenges.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,17 @@ export function normalizeChallengeDetails(v4, v4Filtered, v4User, username) {
8686
registrants: v4.registrants || [],
8787
};
8888

89-
if (challenge.technologies.includes('Data Science') || challenge.subTrack === 'MARATHON_MATCH') {
89+
// v4 Winners have different field names, needs to be normalized to match v4 filtered and v3
90+
challenge.winners = _.map(
91+
v4.winners,
92+
(winner, index) => ({
93+
...winner,
94+
handle: winner.submitter,
95+
placement: winner.rank || index + 1, // Legacy MMs do not have a rank but are sorted by points
96+
}),
97+
);
98+
99+
if (challenge.subTrack === 'MARATHON_MATCH') {
90100
challenge.track = 'DATA_SCIENCE';
91101
}
92102

@@ -120,14 +130,6 @@ export function normalizeChallengeDetails(v4, v4Filtered, v4User, username) {
120130
numSubmissions: v4Filtered.numSubmissions,
121131
groups,
122132
});
123-
124-
/* Taking winners from v3_filtered, because winners are returned empty in v3 */
125-
/* TODO: Enforced due to problems with /v3/challenge/{ID} endpoint */
126-
challenge.winners = v4Filtered.winners || [];
127-
/* TODO: To compenstate the difference in structure of `submissions`
128-
* in v3 and v3Filetered results (existing code needs v4Filtered version).
129-
*/
130-
challenge.submissions = v4Filtered.submissions || [];
131133
}
132134

133135
// Fill missing data from v3_user
@@ -177,14 +179,6 @@ export function normalizeChallenge(challenge, username) {
177179
groups[id] = true;
178180
});
179181
}
180-
181-
_.defaults(challenge, {
182-
communities: new Set([COMPETITION_TRACKS[challenge.track]]),
183-
groups,
184-
registrationOpen,
185-
submissionEndTimestamp: challenge.submissionEndDate,
186-
users: username ? { [username]: true } : {},
187-
});
188182
/* eslint-disable no-param-reassign */
189183
if (!challenge.prizes) challenge.prizes = challenge.prize || [];
190184
if (!challenge.totalPrize) {
@@ -198,6 +192,14 @@ export function normalizeChallenge(challenge, username) {
198192
challenge.subTrack = 'MARATHON_MATCH';
199193
}
200194
/* eslint-enable no-param-reassign */
195+
196+
_.defaults(challenge, {
197+
communities: new Set([COMPETITION_TRACKS[challenge.track]]),
198+
groups,
199+
registrationOpen,
200+
submissionEndTimestamp: challenge.submissionEndDate,
201+
users: username ? { [username]: true } : {},
202+
});
201203
}
202204

203205
/**

0 commit comments

Comments
 (0)