Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
util.log("no data: status="+fetchResponse.status+" "+fetchResponse.url);
return [];
}
} else if (fetchResponse.status === 404 ) {
return []; // empty array means no data
} else {
// $FlowFixMe
throw new Error("fetch error: "+fetchResponse.ok+" "+fetchResponse.status+" "+fetchResponse.url);
}
}).catch(err => {
util.log("caught fetch err, continuing with empty: "+err);
return [];
});
});
return RSVP.all(promiseArray).then(pArray => {
let dataRecords: Array = [];
pArray.forEach(p => {
dataRecords = dataRecords.concat(p);
});
return dataRecords;
});
}
let learningMaterialsToCopy = yield sessionToCopy.get('learningMaterials');
for (let i = 0; i < learningMaterialsToCopy.length; i++){
let learningMaterialToCopy = learningMaterialsToCopy.toArray()[i];
let lm = yield learningMaterialToCopy.get('learningMaterial');
let learningMaterial = store.createRecord(
'sessionLearningMaterial',
learningMaterialToCopy.getProperties('notes', 'required', 'publicNotes', 'position')
);
learningMaterial.set('learningMaterial', lm);
learningMaterial.set('session', session);
toSave.pushObject(learningMaterial);
}
// save the session first to fill out relationships with the session id
yield session.save();
yield all(toSave.invoke('save'));
//parse objectives last because it is a many2many relationship
//and ember data tries to save it too soon
let relatedObjectives = yield sessionToCopy.get('objectives');
let objectivesToCopy = relatedObjectives.sortBy('id');
for (let i = 0; i < objectivesToCopy.length; i++){
let objectiveToCopy = objectivesToCopy.toArray()[i];
let meshDescriptors = yield objectiveToCopy.get('meshDescriptors');
let objective = store.createRecord(
'objective',
objectiveToCopy.getProperties('title', 'position')
);
objective.set('meshDescriptors', meshDescriptors);
objective.set('sessions', [session]);
//save each objective as it is created to preserve to sequence order of objectives by id
yield objective.save();
export function asyncEqual(a, b, message) {
return all([resolve(a), resolve(b)]).then(
this.wait(array => {
let actual = array[0];
let expected = array[1];
let result = actual === expected;
this.pushResult({ result, actual, expected, message });
})
);
}
.send(body)
.expect('Content-Type', /json/)
.expect(201)
.end(function (error, response) {
should.not.exist(error);
var resources = JSON.parse(response.text)[key];
ids[key] = ids[key] || [];
resources.forEach(function (resource) {
ids[key].push(resource.id);
});
resolve();
});
}));
});
RSVP.all(createResources).then(function () {
done();
}, function () {
throw new Error('Failed to create resources.');
});
});
return RSVP.all(promises).then(resolve, reject);
}
file = config.prelude(key) + entries.map(serializeEntry).join('\n') + config.footer;
writefile({
data: file,
filepath: dest,
minify: minify
}, resolve, reject);
console.log('wrote locale data to: ' + dest);
});
}.bind(this));
return RSVP.all(writePromises);
}
var location = options.baseUrl + '/';
location += !!options.namespace ? options.namespace + '/' : '';
location += collection + '/' + primaryResources.map(function (resource) {
return resource.id;
}).join(',');
res.set('Location', location);
if (Object.keys(linkedResources).length) {
var promises = [];
body.linked = linkedResources;
primaryResources.forEach(function (resource) {
promises.push(adapter.find(name, resource.id));
});
RSVP.all(promises).then(function (resources) {
return RSVP.all(resources.map(function (resource) {
return afterTransform(resource, req, res);
}));
}).then(function (resources) {
body[collection] = resources;
sendResponse(req, res, 201, body);
});
} else {
body[collection] = primaryResources;
sendResponse(req, res, 201, body);
}
}, function (error) {
sendError(req, res, 500, error);
async _saveSkills(task) {
let unsavedTaskSkills = get(this, 'unsavedTaskSkills');
let promises = unsavedTaskSkills.map((skill) => this._createTaskSkill(skill, task));
return RSVP.all(promises).then(() => task);
}
});
return get(this, 'globalStore').findAll('token').then((tokens) => {
const promises = [];
tokens.forEach((token) => {
if ( !token.current ) {
promises.push(token.delete());
}
});
return all(promises).catch(() => resolve());
});
} else {
model() {
const job = this.modelFor('jobs.job');
return job && RSVP.all([job.get('deployments'), job.get('versions')]).then(() => job);
}
course.get('objectives').then(objectives => {
RSVP.all(objectives.invoke('removeParentWithProgramYears', programYearsToRemove)).then(()=> {
course.save().then(()=>{
this.set('isManaging', false);
this.set('bufferedCohorts', []);
this.set('isSaving', false);
});
});
});