File tree 2 files changed +37
-3
lines changed
2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,17 @@ async function checkErrorV5(res) {
150
150
} ;
151
151
}
152
152
153
+ /**
154
+ * check if is marathon match challenge
155
+ * @param {Object } challenge challenge object
156
+ * @return {Boolean }
157
+ * @private
158
+ */
159
+ function checkMM ( challenge ) {
160
+ const tags = _ . get ( challenge , 'tags' ) || [ ] ;
161
+ return tags . includes ( 'Marathon Match' ) ;
162
+ }
163
+
153
164
/**
154
165
* Challenge service.
155
166
*/
@@ -390,13 +401,17 @@ class ChallengesService {
390
401
. then ( res => res . challenges ) ;
391
402
}
392
403
404
+ const isMM = checkMM ( challenge ) ;
405
+
393
406
if ( challenge ) {
394
407
registrants = await this . getChallengeRegistrants ( challenge . id ) ;
395
408
396
409
// This TEMP fix to colorStyle, this will be fixed with issue #4530
397
- registrants = _ . map ( registrants , r => ( {
398
- ...r , colorStyle : 'color: #151516' ,
399
- } ) ) ;
410
+ registrants = await Promise . all ( _ . map ( registrants , async r => ( {
411
+ ...r ,
412
+ colorStyle : 'color: #151516' ,
413
+ rating : isMM ? await this . private . memberService . getMMRating ( r . memberHandle ) : r . rating ,
414
+ } ) ) ) ;
400
415
401
416
/* Prepare data to logged user */
402
417
if ( memberId ) {
Original file line number Diff line number Diff line change @@ -109,6 +109,25 @@ class MembersService {
109
109
) ;
110
110
}
111
111
112
+ /**
113
+ * Gets member Marathon Match rating.
114
+ * @param {String } handle
115
+ * @returns {Promise } resolves to the rating
116
+ */
117
+ async getMMRating ( handle ) {
118
+ const res = await this . private . apiV5 . get ( `/members/${ handle } /stats` ) ;
119
+ const stats = await res . json ( ) ;
120
+
121
+ if ( stats . length === 1 ) {
122
+ if ( stats [ 0 ] . DATA_SCIENCE != null && stats [ 0 ] . DATA_SCIENCE . MARATHON_MATCH != null ) {
123
+ return stats [ 0 ] . DATA_SCIENCE . MARATHON_MATCH . rank . rating ;
124
+ }
125
+ return 0 ;
126
+ }
127
+
128
+ return 0 ;
129
+ }
130
+
112
131
/**
113
132
* Gets member statistics history
114
133
* @param {String } handle
You can’t perform that action at this time.
0 commit comments