* fix(logs): Remove console.log's * chore(challengeMap): challengeMap -> completedChallenges * chore(userModel): Update user model * feat(userIDs): Add user ident fields * chore(github): Remove more refs to github data
33 lines
807 B
JavaScript
33 lines
807 B
JavaScript
import { find } from 'lodash';
|
|
|
|
export const jsProjectSuperBlock = 'javascript-algorithms-and-data-structures';
|
|
|
|
export function buildUserProjectsMap(projectBlock, completedChallenges) {
|
|
const {
|
|
challenges,
|
|
superBlock
|
|
} = projectBlock;
|
|
return {
|
|
[superBlock]: challenges.reduce((solutions, current) => {
|
|
const { id } = current;
|
|
const completed = find(
|
|
completedChallenges,
|
|
({ id: completedId }) => completedId === id
|
|
);
|
|
let solution = '';
|
|
if (superBlock === jsProjectSuperBlock) {
|
|
solution = {};
|
|
}
|
|
if (completed) {
|
|
solution = 'solution' in completed ?
|
|
completed.solution :
|
|
completed.files;
|
|
}
|
|
return {
|
|
...solutions,
|
|
[current.title]: solution
|
|
};
|
|
}, {})
|
|
};
|
|
}
|