Skip to content

fix for issue #4552 #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/services/challenges.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,25 @@ export const ORDER_BY = {
SUBMISSION_END_DATE: 'submissionEndDate',
};

export function fixColorStyle(registrant) {
/* eslint-disable no-param-reassign */
// set default color
registrant.colorStyle = 'color: #555555'; // grey
if (registrant.rating) {
if (registrant.rating >= 2200) {
registrant.colorStyle = 'color: #EA1900'; // red
} else if (registrant.rating >= 1500 && registrant.rating <= 2199) {
registrant.colorStyle = 'color: #F2C900'; // yellow
} else if (registrant.rating >= 1200 && registrant.rating <= 1499) {
registrant.colorStyle = 'color: #4C50D9'; // blue
} else if (registrant.rating >= 900 && registrant.rating <= 1199) {
registrant.colorStyle = 'color: #258205'; // green
}
}
/* eslint-disable no-param-reassign */
return registrant;
}

/**
* Normalizes a regular challenge object received from the backend.
* NOTE: This function is copied from the existing code in the challenge listing
@@ -340,11 +359,7 @@ class ChallengesService {

if (challenge) {
registrants = await this.getChallengeRegistrants(challenge.id);

// This TEMP fix to colorStyle, this will be fixed with issue #4530
registrants = _.map(registrants, r => ({
...r, colorStyle: 'color: #151516',
}));
registrants = _.map(registrants, registrant => fixColorStyle(registrant));

/* Prepare data to logged user */
if (memberId) {
12 changes: 10 additions & 2 deletions src/services/submissions.js
Original file line number Diff line number Diff line change
@@ -60,8 +60,16 @@ class SubmissionsService {

const url = `/submissions?${qs.stringify(query, { encode: false })}`;
return this.private.apiV5.get(url)
.then(checkErrorV5)
.then(res => res.result);
.then(res => (res.ok ? res.json() : new Error(res.statusText)))
.then((res) => {
const unique = [];
res.forEach((x) => {
if (unique.filter(a => a.updatedBy === x.updatedBy).length < 0) {
unique.push(x);
}
});
return unique;
});
}

/**