Skip to content

Fix topgear profile #310

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

Merged
merged 6 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- attach_workspace:
at: .
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm publish
- run: npm publish --tag test-release
# dont change anything
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "1.1.7",
"version": "1000.27.13",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function getStatsInit(handle, uuid) {
* @static
* @desc Create an action that loads member statistics.
* @param {String} handle Member handle.
* @param {String} groupIds Group ids.
* @param {Array<String>|String} groupIds Group ids.
* @param {String} uuid Operation UUID.
* @param {String} tokenV3 v3 auth token.
* @return {Action}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function getStatsInit() {}
* @static
* @desc Creates an action that loads member's stats.
* @param {String} handle Member handle.
* @param {String} groupIds Group ids.
* @param {Array<String>|String} groupIds Group ids.
* @return {Action}
*/
function getStatsDone(handle, groupIds) {
Expand Down
27 changes: 20 additions & 7 deletions src/services/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,30 @@ class MembersService {
/**
* Gets member statistics.
* @param {String} handle
* @param {String} groupIds
* @param {Array<String>|String} groupIds
* @return {Promise} Resolves to the stats object.
*/
async getStats(handle, groupIds) {
let res;
if (groupIds) {
res = await this.private.api.get(`/members/${handle}/stats?groupIds=${groupIds}`);
} else {
res = await this.private.api.get(`/members/${handle}/stats`);
if (!groupIds || (_.isArray(groupIds) && groupIds.length === 0)) {
const res = await this.private.api.get(`/members/${handle}/stats`);
return getApiResponsePayload(res);
}
return getApiResponsePayload(res);

const groupIdsArray = _.isArray(groupIds) ? groupIds : _.split(groupIds, ',');
const groupIdChunks = _.chunk(groupIdsArray, 50);

const getStatRequests = _.map(groupIdChunks, async (groupIdChunk) => {
const res = await this.private.api.get(`/members/${handle}/stats?groupIds=${_.join(groupIdChunk)}`);
return getApiResponsePayload(res, false);
});
const results = await Promise.all(getStatRequests);

return _.uniqBy(
_.flatten(
_.filter(results, _.isArray),
),
item => item.groupId,
);
}

/**
Expand Down