Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
Transform for loops into forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
CaroFG committed Jan 6, 2021
1 parent 458a627 commit d1d382d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions setup/setup.js
Expand Up @@ -93,12 +93,13 @@ const rankingRulesDesc = [
// Add documents
const batchedDataSet = batch(processedDataSet, 10000)
console.log('Adding documents...')
for (let i = 0; i < batchedDataSet.length; i++) {
const { updateId } = await index.addDocuments(batchedDataSet[i])
batchedDataSet.forEach(async (batch) => {
const { updateId } = await index.addDocuments(batch)
await index.waitForPendingUpdate(updateId, {
timeOutMs: 100000
})
}
})

console.log('Documents added to "artWorks" index.')

// ArtWorks with ASC order
Expand All @@ -108,12 +109,12 @@ const rankingRulesDesc = [
console.log('Settings added to "artWorksAsc" index.')

console.log('Adding documents...')
for (let i = 0; i < batchedDataSet.length; i++) {
const { updateId } = await indexAsc.addDocuments(batchedDataSet[i])
await indexAsc.waitForPendingUpdate(updateId, {
batchedDataSet.forEach(async (batch) => {
const { updateId } = await indexAsc.addDocuments(batch)
await index.waitForPendingUpdate(updateId, {
timeOutMs: 100000
})
}
})
console.log('Documents added to "artWorksAsc" index.')

// ArtWorks with DESC order
Expand All @@ -122,12 +123,12 @@ const rankingRulesDesc = [
await indexDesc.updateSettings(settings)
console.log('Settings added to "artWorksDesc" index.')
console.log('Adding documents...')
for (let i = 0; i < batchedDataSet.length; i++) {
const { updateId } = await indexDesc.addDocuments(batchedDataSet[i])
await indexDesc.waitForPendingUpdate(updateId, {
batchedDataSet.forEach(async (batch) => {
const { updateId } = await indexDesc.addDocuments(batch)
await index.waitForPendingUpdate(updateId, {
timeOutMs: 100000
})
}
})
console.log('Documents added to "artWorksDesc" index.')
})()

Expand Down

0 comments on commit d1d382d

Please sign in to comment.