Skip to content

Commit 6893832

Browse files
Merge pull request #310 from topcoder-platform/fix-topgear-profile
Fix topgear profile
2 parents 355429e + eece83a commit 6893832

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- attach_workspace:
2929
at: .
3030
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
31-
- run: npm publish
31+
- run: npm publish --tag test-release
3232
# dont change anything
3333
workflows:
3434
version: 2

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3232
"test": "npm run lint && npm run jest"
3333
},
34-
"version": "1.1.7",
34+
"version": "1000.27.13",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

src/actions/members.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async function getStatsInit(handle, uuid) {
114114
* @static
115115
* @desc Create an action that loads member statistics.
116116
* @param {String} handle Member handle.
117-
* @param {String} groupIds Group ids.
117+
* @param {Array<String>|String} groupIds Group ids.
118118
* @param {String} uuid Operation UUID.
119119
* @param {String} tokenV3 v3 auth token.
120120
* @return {Action}

src/actions/profile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function getStatsInit() {}
132132
* @static
133133
* @desc Creates an action that loads member's stats.
134134
* @param {String} handle Member handle.
135-
* @param {String} groupIds Group ids.
135+
* @param {Array<String>|String} groupIds Group ids.
136136
* @return {Action}
137137
*/
138138
function getStatsDone(handle, groupIds) {

src/services/members.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,30 @@ class MembersService {
8383
/**
8484
* Gets member statistics.
8585
* @param {String} handle
86-
* @param {String} groupIds
86+
* @param {Array<String>|String} groupIds
8787
* @return {Promise} Resolves to the stats object.
8888
*/
8989
async getStats(handle, groupIds) {
90-
let res;
91-
if (groupIds) {
92-
res = await this.private.api.get(`/members/${handle}/stats?groupIds=${groupIds}`);
93-
} else {
94-
res = await this.private.api.get(`/members/${handle}/stats`);
90+
if (!groupIds || (_.isArray(groupIds) && groupIds.length === 0)) {
91+
const res = await this.private.api.get(`/members/${handle}/stats`);
92+
return getApiResponsePayload(res);
9593
}
96-
return getApiResponsePayload(res);
94+
95+
const groupIdsArray = _.isArray(groupIds) ? groupIds : _.split(groupIds, ',');
96+
const groupIdChunks = _.chunk(groupIdsArray, 50);
97+
98+
const getStatRequests = _.map(groupIdChunks, async (groupIdChunk) => {
99+
const res = await this.private.api.get(`/members/${handle}/stats?groupIds=${_.join(groupIdChunk)}`);
100+
return getApiResponsePayload(res, false);
101+
});
102+
const results = await Promise.all(getStatRequests);
103+
104+
return _.uniqBy(
105+
_.flatten(
106+
_.filter(results, _.isArray),
107+
),
108+
item => item.groupId,
109+
);
97110
}
98111

99112
/**

0 commit comments

Comments
 (0)