7631_testToMaster_2426 #2634

Merged
alexm merged 147 commits from 7631_testToMaster_2426 into master 2024-06-25 06:36:59 +00:00
1 changed files with 6 additions and 4 deletions
Showing only changes of commit 39381a4a7c - Show all commits

View File

@ -41,14 +41,16 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
ids = ids.split(','); const downloadAddZip = async id => {
for (const id of ids) {
ctx.args = ctx.args || {}; ctx.args = ctx.args || {};
ctx.args.id = Number(id); ctx.args.id = Number(id);
const [data] = await models.Route.cmr(ctx, myOptions); const [data] = await models.Route.cmr(ctx, myOptions);
zip.file(`${id}.pdf`, data, {binary: true}); zip.file(`${id}.pdf`, data, {binary: true});
} };
ids = ids.split(',');
const promises = ids.map(id => downloadAddZip(id));
await Promise.all(promises);
const zipStream = zip.generateNodeStream({streamFiles: true}); const zipStream = zip.generateNodeStream({streamFiles: true});
return [zipStream, 'application/zip', `filename="cmrs.zip"`]; return [zipStream, 'application/zip', `filename="cmrs.zip"`];
}; };