Skip to content

Commit fddd3c7

Browse files
authored
Merge pull request #202 from simranb86/issue_4552
fix for issue #4552
2 parents f5471db + 46e675c commit fddd3c7

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/services/challenges.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ export const ORDER_BY = {
1919
SUBMISSION_END_DATE: 'submissionEndDate',
2020
};
2121

22+
export function fixColorStyle(registrant) {
23+
/* eslint-disable no-param-reassign */
24+
// set default color
25+
registrant.colorStyle = 'color: #555555'; // grey
26+
if (registrant.rating) {
27+
if (registrant.rating >= 2200) {
28+
registrant.colorStyle = 'color: #EA1900'; // red
29+
} else if (registrant.rating >= 1500 && registrant.rating <= 2199) {
30+
registrant.colorStyle = 'color: #F2C900'; // yellow
31+
} else if (registrant.rating >= 1200 && registrant.rating <= 1499) {
32+
registrant.colorStyle = 'color: #4C50D9'; // blue
33+
} else if (registrant.rating >= 900 && registrant.rating <= 1199) {
34+
registrant.colorStyle = 'color: #258205'; // green
35+
}
36+
}
37+
/* eslint-disable no-param-reassign */
38+
return registrant;
39+
}
40+
2241
/**
2342
* Normalizes a regular challenge object received from the backend.
2443
* NOTE: This function is copied from the existing code in the challenge listing
@@ -340,11 +359,7 @@ class ChallengesService {
340359

341360
if (challenge) {
342361
registrants = await this.getChallengeRegistrants(challenge.id);
343-
344-
// This TEMP fix to colorStyle, this will be fixed with issue #4530
345-
registrants = _.map(registrants, r => ({
346-
...r, colorStyle: 'color: #151516',
347-
}));
362+
registrants = _.map(registrants, registrant => fixColorStyle(registrant));
348363

349364
/* Prepare data to logged user */
350365
if (memberId) {

src/services/submissions.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ class SubmissionsService {
6060

6161
const url = `/submissions?${qs.stringify(query, { encode: false })}`;
6262
return this.private.apiV5.get(url)
63-
.then(checkErrorV5)
64-
.then(res => res.result);
63+
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
64+
.then((res) => {
65+
const unique = [];
66+
res.forEach((x) => {
67+
if (unique.filter(a => a.updatedBy === x.updatedBy).length < 0) {
68+
unique.push(x);
69+
}
70+
});
71+
return unique;
72+
});
6573
}
6674

6775
/**

0 commit comments

Comments
 (0)