mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-12 02:11:57 +00:00
Allow to reindex region (#8610)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
2326643ccc
commit
10c30e6cc0
@ -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>', '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')
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user