Skip to content

Fix getChallengeRegistrants filter to not logged user #223

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

Open
wants to merge 6 commits into
base: integration-v5-challenge-api
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
fix(members-service): fetch only active challenges
At the `getUserResources` function, it will fetch only Active challenges.

Reference topcoder-platform/community-app#4714
  • Loading branch information
cagdas001 committed Aug 12, 2020
commit b07363e003fd059c2a6af3d188439ae5c2e8aee0
8 changes: 5 additions & 3 deletions src/services/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/* global XMLHttpRequest */
import _ from 'lodash';
import qs from 'qs';
import { decodeToken } from 'tc-accounts';
import logger from '../utils/logger';
import { getApiResponsePayload } from '../utils/tc';
import { getApi } from './api';
Expand Down Expand Up @@ -329,7 +330,8 @@ class MembersService {
* @param {Array} challengeId the challenge id
*/
async getChallengeResources(challengeId) {
const url = `/resources?challengeId=${challengeId}`;
const user = decodeToken(this.private.tokenV3);
const url = `/resources?challengeId=${challengeId}&memberId=${user.userId}`;
let res = null;

try {
Expand All @@ -346,14 +348,14 @@ class MembersService {
* @param {Array} memberId the member id
*/
async getUserResources(memberId) {
const url = `/resources/${memberId}/challenges`;
const url = `/challenges?status=Active&memberId=${memberId}`;
const res = await this.private.apiV5.get(url);
const challenges = await res.json();
const roles = await this.getResourceRoles();
const calls = [];

challenges.forEach(async (ch) => {
calls.push(this.getChallengeResources(ch));
calls.push(this.getChallengeResources(ch.id));
});

return Promise.all(calls).then((resources) => {
Expand Down