diff --git a/ee/vulnerability-dashboard/scripts/update-reports.js b/ee/vulnerability-dashboard/scripts/update-reports.js index 8190194d4400..92128905370d 100644 --- a/ee/vulnerability-dashboard/scripts/update-reports.js +++ b/ee/vulnerability-dashboard/scripts/update-reports.js @@ -386,7 +386,10 @@ module.exports = { sails.log.warn(`Dry run: ${hostRecordsToUpdate.length} hosts will be updated with new information. (Fleet returned them in the API.)`); } else { sails.log(`Creating ${newRecordsForUnrecognizedHosts.length} host records… `); - await Host.createEach(newRecordsForUnrecognizedHosts); + let batchedNewRecordsForUnrecognizedHosts = _.chunk(newRecordsForUnrecognizedHosts, 500); + for(let batch of batchedNewRecordsForUnrecognizedHosts){ + await Host.createEach(batch); + } for(let hostUpdate of hostRecordsToUpdate){ await Host.updateOne({id: hostUpdate.id}).set(_.omit(hostUpdate, 'id')); } @@ -696,7 +699,10 @@ module.exports = { totalNumberOfHostRecordsCreated += newRecordsForUnrecognizedHosts.length; totalNumberOfHostRecordsUpdated += hostRecordsToUpdate.length; sails.log.verbose(`Creating ${newRecordsForUnrecognizedHosts.length} new host records…`); - await Host.createEach(newRecordsForUnrecognizedHosts); + let batchedNewRecordsForUnrecognizedHosts = _.chunk(newRecordsForUnrecognizedHosts, 500); + for(let batch of batchedNewRecordsForUnrecognizedHosts){ + await Host.createEach(batch); + } sails.log.verbose(`Updating ${hostRecordsToUpdate.length} host records…`); for(let hostUpdate of hostRecordsToUpdate){ await Host.updateOne({id: hostUpdate.id}).set(_.omit(hostUpdate, 'id'));