Skip to content

Code 30090056 #65

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 3 commits into from
May 10, 2019
Merged
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
3 changes: 3 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
@@ -426,14 +426,17 @@ Object {
"countReset": [Function],
"debug": [Function],
"dir": [Function],
"dirxml": [Function],
"error": [Function],
"group": [Function],
"groupCollapsed": [Function],
"groupEnd": [Function],
"info": [Function],
"log": [Function],
"table": [Function],
"time": [Function],
"timeEnd": [Function],
"timeLog": [Function],
"trace": [Function],
"warn": [Function],
},
23 changes: 12 additions & 11 deletions src/actions/challenge-listing.js
Original file line number Diff line number Diff line change
@@ -197,26 +197,27 @@ function getActiveChallengesDone(
}).catch(() => ({ challenges: [] })));
}
return Promise.all(calls).then(([ch, uch]) => {
let fullCH = ch;
/* uch array contains challenges where the user is participating in
* some role. The same challenge are already listed in res array, but they
* are not attributed to the user there. This block of code marks user
* challenges in an efficient way. */
if (uch) {
const map = {};
uch.challenges.forEach((item) => { map[item.id] = item; });
ch.challenges.forEach((item) => {
if (map[item.id]) {
/* It is fine to reassing, as the array we modifying is created just
* above within the same function. */
/* eslint-disable no-param-reassign */
item.users[user] = true;
item.userDetails = map[item.id].userDetails;
/* eslint-enable no-param-reassign */
}
uch.challenges.forEach((item) => {
map[item.id] = item;
/* eslint-disable no-param-reassign */
item.users[user] = true;
item.userDetails = map[item.id].userDetails;
/* eslint-enable no-param-reassign */
});
}

let { challenges, meta } = ch;
if (uch) {
fullCH = uch;
}
let { challenges } = fullCH;
let { meta } = ch;
// filter by date range and re-compute meta
// we can safely remove the next two lines when backend support date range
challenges = filterUtil.filterByDate(challenges, frontFilter);