Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_compressFiles(distDir, distFiles, filePattern, ignorePattern, keep, format) {
var filesToCompress = distFiles.filter(minimatch.filter(filePattern, { matchBase: true }));
if (ignorePattern != null) {
filesToCompress = filesToCompress.filter(function(path){
return !minimatch(path, ignorePattern, { matchBase: true });
});
}
return RSVP.map(filesToCompress, this._compressFile.bind(this, distDir, keep, format));
},
_compressFile(distDir, keep, format, filePath) {
save: task(function* () {
yield timeout(10);
const finalData = this.finalData;
const done = this.done;
const flashMessages = this.flashMessages;
const treeGroups = yield map(finalData, async ({ learnerGroup, user }) => {
return learnerGroup.addUserToGroupAndAllParents(user);
});
const flat = treeGroups.reduce((flattened, arr) => {
return flattened.pushObjects(arr);
}, []);
const groupsToSave = flat.uniq();
yield all(groupsToSave.invoke('save'));
flashMessages.success('general.savedSuccessfully');
done();
}),
});
stewardsBySchool: computed('stewards.[]', async function() {
const stewards = this.stewards;
const stewardObjects = await map(stewards.toArray(), async steward => {
const school = await steward.get('school');
const department = await steward.get('department');
return {
school,
department,
};
});
const schools = stewardObjects.uniqBy('school.id');
const stewardsBySchool = schools.map(schoolObj => {
const departments = stewardObjects.filter(obj => {
return obj.school.get('id') === schoolObj.school.get('id') &&
isPresent(obj.department);
}).mapBy('department');
delete schoolObj.department;
schoolObj.departments = departments;
sessionObjects: computed('course', 'sessions.[]', async function(){
const i18n = this.get('i18n');
const permissionChecker = this.get('permissionChecker');
const course = this.get('course');
const sessions = await this.get('sessions');
const sessionObjects = await map(sessions.toArray(), async session => {
const canDelete = await permissionChecker.canDeleteSession(session);
const canUpdate = await permissionChecker.canUpdateSession(session);
let sessionObject = {
session,
course,
canDelete,
canUpdate,
id: session.get('id'),
title: session.get('title'),
instructionalNotes: session.get('instructionalNotes'),
isPublished: session.get('isPublished'),
isNotPublished: session.get('isNotPublished'),
isScheduled: session.get('isScheduled'),
};
const sessionType = await session.get('sessionType');
sessionObject.sessionTypeTitle = sessionType.get('title');
.then(promises => RSVP.map(promises, prepareConfirm))
.then(finishProcessingForInstall)
schoolData: computed('programYear.stewards.[]', async function(){
const programYear = this.programYear;
if (isEmpty(programYear)) {
return [];
}
const stewards = await programYear.get('stewards');
const stewardObjects = await map(stewards.toArray(), async steward => {
const school = await steward.get('school');
const department = await steward.get('department');
const departmentId = isPresent(department)?department.get('id'):0;
return {
schoolId: school.get('id'),
schoolTitle: school.get('title'),
departmentId
};
});
const schools = stewardObjects.uniqBy('schoolId');
const schoolData = schools.map(obj => {
const departments = stewardObjects.filterBy('schoolId', obj.schoolId);
delete obj.departmentId;
obj.departmentCount = departments.length;
return obj;
cohortProxies: computed('cohorts.[]', 'programs.[]', async function() {
const courseObjective = this.get('courseObjective');
const cohorts = await this.get('cohorts');
const cohortProxies = await map(cohorts.toArray(), async cohort => {
const programYear = await cohort.get('programYear');
const objectives = await programYear.get('objectives');
let objectiveProxies = objectives.map(objective => {
return objectiveProxy.create({
content: objective,
courseObjective,
});
});
const program = await programYear.get('program');
const programTitle = program.get('title');
let cohortTitle = cohort.get('title');
if (isEmpty(cohortTitle)) {
const i18n = this.get('i18n');
const classOfYear = await cohort.get('classOfYear');
cohortTitle = i18n.t('general.classOf', {year: classOfYear});
}
parseFile: task(function* (file) {
const store = this.store;
const intl = this.intl;
const learnerGroup = this.learnerGroup;
const cohort = yield learnerGroup.get('cohort');
const proposedUsers = yield this.getFileContents(file);
const data = yield map(proposedUsers, async ({firstName, lastName, campusId, subGroupName }) => {
const errors = [];
const warnings = [];
if (isEmpty(firstName)) {
errors.push(intl.t('errors.required', {description: intl.t('general.firstName')}));
}
if (isEmpty(lastName)) {
errors.push(intl.t('errors.required', {description: intl.t('general.lastName')}));
}
if (isEmpty(campusId)) {
errors.push(intl.t('errors.required', {description: intl.t('general.campusId')}));
}
let userRecord = null;
if (errors.length === 0) {
const users = await store.query('user', {
filters: {
campusId,
.then(() => {
return RSVP.map(srcPaths, srcPath => {
let slug = path.basename(srcPath, '.js');
let title = capitalizeFirstLetter(slug.replace('-', ' '));
return writeDocsFile(srcPath, destDir, { slug, title });
});
})
}
let cohorts = await map(learnerGroups.toArray(), (group => group.get('cohort')));
let summaryBlocks = cohorts.reduce((set, cohort) => {
let key = 'cohort' + cohort.get('id');
if (!Object.keys(set).includes(key)) {
set[key] = {
cohort,
count: 0
};
}
set[key].count++;
return set;
}, {});
return await map(Object.keys(summaryBlocks), async key => {
const cohort = summaryBlocks[key].cohort;
const count = summaryBlocks[key].count;
const program = await cohort.get('program');
const title = [program.title, cohort.title].join(' ');
return {
title,
count
};
});
}),
});