From 39a0382318dbd65fcccf3da65b2954ab698fe7f5 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 28 Jul 2024 21:07:07 +0200 Subject: [PATCH] Sequencial instead of parallel fetching --- src/synchro.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/synchro.ts b/src/synchro.ts index 0c249d1..5e365ea 100644 --- a/src/synchro.ts +++ b/src/synchro.ts @@ -1,6 +1,7 @@ import { convertEndpointChangeToMeiliDocuments } from "src/convert"; import { meili, payload } from "src/services"; import { MeiliIndexes } from "src/shared/meilisearch/constants"; +import type { MeiliDocument } from "src/shared/meilisearch/types"; export const synchronizeMeiliDocs = async () => { const version = await meili.getVersion(); @@ -31,9 +32,10 @@ export const synchronizeMeiliDocs = async () => { const allChanges = (await payload.getAll()).data; - const documents = ( - await Promise.all(allChanges.map(convertEndpointChangeToMeiliDocuments)) - ).flat(); + const documents: MeiliDocument[] = []; + for (const change of allChanges) { + documents.push(...(await convertEndpointChangeToMeiliDocuments(change))); + } console.log("Adding", documents.length, "documents to Meilisearch");