Skip to content

Commit aeb69b5

Browse files
Get SRMs via V4 API for now
1 parent befdfdf commit aeb69b5

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

src/actions/members.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ async function getUserSRMInit(handle, uuid) {
283283
* @static
284284
* @desc Create an action that loads the member SRM.
285285
* @param {String} uuid Operation UUID.
286-
* @param {Number} memberId Member ID.
286+
* @param {String} handle Member handle.
287287
* @param {String} tokenV3 v3 auth token.
288288
* @param {Number} start page.
289289
* @param {Number} page size.
290290
* @param {Boolean} whether to refresh.
291291
* @return {Action}
292292
*/
293293
async function getUserSRMDone(
294-
uuid, memberId, tokenV3, pageNum, pageSize,
294+
uuid, handle, tokenV3, pageNum, pageSize,
295295
refresh,
296296
) {
297297
const filter = {
@@ -306,11 +306,11 @@ async function getUserSRMDone(
306306
};
307307

308308
const service = getChallengesService(tokenV3);
309-
return service.getUserSrms(memberId, params).then(res => ({
309+
return service.getUserSrms(handle, params).then(res => ({
310310
uuid,
311311
srms: res,
312312
refresh,
313-
memberId,
313+
handle,
314314
}));
315315
}
316316

src/services/challenges.js

+5-27
Original file line numberDiff line numberDiff line change
@@ -387,21 +387,10 @@ class ChallengesService {
387387
/**
388388
* Gets SRM matches.
389389
* @param {Object} params
390-
* @param {string} typeId Challenge SRM TypeId
391390
* @return {Promise}
392391
*/
393392
async getSrms(params) {
394-
const typeId = await this.getChallengeTypeId('DEVELOP_SINGLE_ROUND_MATCH');
395-
if (!typeId) {
396-
return null;
397-
}
398-
399-
const newParams = {
400-
...params,
401-
typeId,
402-
};
403-
404-
const res = await this.private.apiV5.get(`/challenges?${qs.stringify(newParams)}`);
393+
const res = await this.private.api.get(`/srms/?${qs.stringify(params)}`);
405394
return getApiResponsePayload(res);
406395
}
407396

@@ -464,24 +453,13 @@ class ChallengesService {
464453

465454
/**
466455
* Gets SRM matches related to the user.
467-
* @param {Number} memberId
456+
* @param {String} handle
468457
* @param {Object} params
469458
* @return {Promise}
470459
*/
471-
async getUserSrms(memberId, params) {
472-
const typeId = await this.getChallengeTypeId('DEVELOP_SINGLE_ROUND_MATCH');
473-
474-
if (!typeId) {
475-
return null;
476-
}
477-
478-
const newParams = {
479-
...params,
480-
typeId,
481-
memberId,
482-
};
483-
484-
const res = await this.private.apiV5.get(`/challenges?${qs.stringify(newParams)}`);
460+
async getUserSrms(handle, params) {
461+
const url = `/members/${handle}/srms/?${qs.stringify(params)}`;
462+
const res = await this.private.api.get(url);
485463
return getApiResponsePayload(res);
486464
}
487465

0 commit comments

Comments
 (0)