fix(path-map): Refactor pathMigrationMap for new curriculum package
This commit is contained in:
committed by
mrugesh mohapatra
parent
bc9b3b4ddd
commit
d52ba8c6fd
25
tools/scripts/seed/createPathMigrationMap.js
Normal file
25
tools/scripts/seed/createPathMigrationMap.js
Normal file
@ -0,0 +1,25 @@
|
||||
const { flatten } = require('lodash');
|
||||
|
||||
const { dasherize } = require('../../../api-server/server/utils');
|
||||
|
||||
function createPathMigrationMap(curriculum) {
|
||||
return Object.keys(curriculum)
|
||||
.map(key => curriculum[key].blocks)
|
||||
.reduce((challenges, current) => {
|
||||
const superChallenges = Object.keys(current).map(
|
||||
key => current[key].challenges
|
||||
);
|
||||
return challenges.concat(flatten(superChallenges));
|
||||
}, [])
|
||||
.filter(({ isPrivate }) => !isPrivate)
|
||||
.reduce((map, challenge) => {
|
||||
const { title, block, superBlock } = challenge;
|
||||
const dashedTitle = dasherize(title);
|
||||
map[dashedTitle] = `/learn/${dasherize(superBlock)}/${dasherize(
|
||||
block
|
||||
)}/${dashedTitle}`;
|
||||
return map;
|
||||
}, {});
|
||||
}
|
||||
|
||||
exports.createPathMigrationMap = createPathMigrationMap;
|
Reference in New Issue
Block a user