Skip to content

Commit 22e5d1b

Browse files
committed
fix for issue #4552
1 parent 0df81e4 commit 22e5d1b

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/services/challenges.js

+21-6
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: #999999';
26+
if (registrant.rating) {
27+
if (registrant.rating >= 2200) {
28+
registrant.colorStyle = 'color: #EE0000';
29+
} else if (registrant.rating >= 1500 && registrant.rating <= 2199) {
30+
registrant.colorStyle = 'color: #DDCC00';
31+
} else if (registrant.rating >= 1200 && registrant.rating <= 1499) {
32+
registrant.colorStyle = 'color: #6666FF';
33+
} else if (registrant.rating >= 900 && registrant.rating <= 1199) {
34+
registrant.colorStyle = 'color: #00A900';
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) {
@@ -363,7 +378,7 @@ class ChallengesService {
363378
// Remove AV Scan, SonarQube Review and Virus Scan review types
364379
const reviewScans = await this.private.submissionsService.getScanReviewIds();
365380
submissions.forEach((s, i) => {
366-
submissions[i].review = _.reject(s.review, r => _.includes(reviewScans, r.typeId));
381+
submissions[i].review = _.reject(s.review, r => r && _.includes(reviewScans, r.typeId));
367382
});
368383

369384
// Add submission date to registrants

src/services/submissions.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ class SubmissionsService {
3737
const url = `/submissions?${qs.stringify(query, { encode: false })}`;
3838
return this.private.apiV5.get(url)
3939
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
40-
.then(res => res);
40+
.then((res) => {
41+
const unique = [];
42+
res.forEach((x) => {
43+
if (unique.filter(a => a.updatedBy === x.updatedBy).length < 0) {
44+
unique.push(x);
45+
}
46+
});
47+
return unique;
48+
});
4149
}
4250

4351
/**

0 commit comments

Comments
 (0)