From af29002d5ddfcc9471f47c17aa566c557dae1ab1 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Wed, 6 Sep 2023 04:09:51 -0400 Subject: [PATCH] log when finished --- .../processors/background/index-all-notes.ts | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/queue/processors/background/index-all-notes.ts b/packages/backend/src/queue/processors/background/index-all-notes.ts index 2fac021cd8..9cd7c1e471 100644 --- a/packages/backend/src/queue/processors/background/index-all-notes.ts +++ b/packages/backend/src/queue/processors/background/index-all-notes.ts @@ -23,21 +23,31 @@ export default async function indexAllNotes( if (scyllaClient) { total = await fetchPostCount(false); - scyllaClient.eachRow("SELECT * FROM note", [], (n, row) => { - if (n % 1000 === 0) { - job.progress(((n / total) * 100).toFixed(1)); - logger.info(`Indexed notes ${n}/${total}`); - } - const note = parseScyllaNote(row); - if (meilisearch) { - meilisearch.ingestNote([note]).then(() => index(note, true)); - } else { - index(note, true); - } - }); + scyllaClient.eachRow( + "SELECT * FROM note", + [], + (n, row) => { + if (n % 1000 === 0) { + job.progress(((n / total) * 100).toFixed(1)); + logger.info(`Indexed notes ${n}/${total}`); + } + const note = parseScyllaNote(row); + if (meilisearch) { + meilisearch.ingestNote([note]).then(() => index(note, true)); + } else { + index(note, true); + } + }, + (err, _) => { + if (err.message) { + logger.error(err); + } else { + logger.info("All notes have been indexed."); + } + done(); + }, + ); - done(); - logger.info("All notes have been indexed."); return; }