Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: #4947 marathon match rating#312

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rakibansary wants to merge1 commit intodevelop
base:develop
Choose a base branch
Loading
fromfix/mm-rating
Open
Show file tree
Hide file tree
Changes fromall 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
21 changes: 18 additions & 3 deletionssrc/services/challenges.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,6 +150,17 @@ async function checkErrorV5(res) {
};
}

/**
* check if is marathon match challenge
* @param {Object} challenge challenge object
* @return {Boolean}
* @private
*/
function checkMM(challenge) {
const tags = _.get(challenge, 'tags') || [];
return tags.includes('Marathon Match');
}

/**
* Challenge service.
*/
Expand DownExpand Up@@ -390,13 +401,17 @@ class ChallengesService {
.then(res => res.challenges);
}

const isMM = checkMM(challenge);

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 = await Promise.all(_.map(registrants, async r => ({
...r,
colorStyle: 'color: #151516',
rating: isMM ? await this.private.memberService.getMMRating(r.memberHandle) : r.rating,
})));

/* Prepare data to logged user */
if (memberId) {
Expand Down
19 changes: 19 additions & 0 deletionssrc/services/members.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -109,6 +109,25 @@ class MembersService {
);
}

/**
* Gets member Marathon Match rating.
* @param {String} handle
* @returns {Promise} resolves to the rating
*/
async getMMRating(handle) {
const res = await this.private.apiV5.get(`/members/${handle}/stats`);
const stats = await res.json();

if (stats.length === 1) {
if (stats[0].DATA_SCIENCE != null && stats[0].DATA_SCIENCE.MARATHON_MATCH != null) {
return stats[0].DATA_SCIENCE.MARATHON_MATCH.rank.rating;
}
return 0;
}

return 0;
}

/**
* Gets member statistics history
* @param {String} handle
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp