From 10c30e6cc0dc0b598319ef7dbaecea0a63c98847 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 17 Apr 2025 22:07:21 +0700 Subject: [PATCH] Allow to reindex region (#8610) Signed-off-by: Andrey Sobolev --- dev/tool/src/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index b5c56a0b7f..d9bead6517 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -229,7 +229,7 @@ export function devTool ( const uri = dbOverride ?? getAccountDBUrl() console.log(`connecting to database '${uri}'...`) - const [accountDb, closeAccountsDb] = await getAccountDB(uri) + const [accountDb, closeAccountsDb] = await getAccountDB(uri, process.env.DB_NS) try { await f(accountDb) } catch (err: any) { @@ -2104,7 +2104,8 @@ export function devTool ( program .command('fulltext-reindex-all') .description('reindex workspaces') - .action(async () => { + .option('--region ', 'region to reindex') + .action(async (cmd: { region?: string }) => { const fulltextUrl = process.env.FULLTEXT_URL if (fulltextUrl === undefined) { console.error('please provide FULLTEXT_URL') @@ -2112,16 +2113,19 @@ export function devTool ( } await withAccountDatabase(async (db) => { - const workspaces = await listWorkspacesRaw(db) + const workspaces = (await listWorkspacesRaw(db, cmd.region)).filter( + (it) => isActiveMode(it.mode) && it.version?.patch === getModelVersion().patch + ) workspaces.sort((a, b) => b.lastVisit - a.lastVisit) + console.log('workspacess to process', workspaces.length) for (const workspace of workspaces) { const wsid = getWorkspaceId(workspace.workspace) const token = generateToken(systemAccountEmail, wsid) - console.log('reindex workspace', workspace) + console.log('reindex workspace', workspace.workspaceUrl) await reindexWorkspace(toolCtx, fulltextUrl, token) - console.log('done', workspace) } + console.log('end-reindex') }) })