From b79d4f757a6f13e2c09298f2eb0cfd4215c6c4a5 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 25 May 2022 00:42:25 +0700 Subject: [PATCH] Allow to rebuild elastic for all workspaces (#1862) Signed-off-by: Andrey Sobolev --- dev/tool/src/index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index fd4a0e9222..f2af03542b 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -244,11 +244,21 @@ program }) program - .command('rebuild-elastic ') + .command('rebuild-elastic [workspace]') .description('rebuild elastic index') .action(async (workspace, cmd) => { - await rebuildElastic(mongodbUri, workspace, minio, elasticUrl) - console.log('rebuild end') + return await withDatabase(mongodbUri, async (db) => { + if (workspace === undefined) { + const workspaces = await listWorkspaces(db) + + for (const w of workspaces) { + await rebuildElastic(mongodbUri, w.workspace, minio, elasticUrl) + } + } else { + await rebuildElastic(mongodbUri, workspace, minio, elasticUrl) + console.log('rebuild end') + } + }) }) program